Skip to content

dev: replace sliceutil package with exp/slices #3830

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ require (
github.com/ykadowak/zerologlint v0.1.1
gitlab.com/bosi/decorder v0.2.3
go.tmz.dev/musttag v0.6.1
golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea
golang.org/x/tools v0.8.0
gopkg.in/yaml.v3 v3.0.1
honnef.co/go/tools v0.4.3
Expand Down Expand Up @@ -182,7 +183,6 @@ require (
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect
golang.org/x/exp/typeparams v0.0.0-20230224173230-c95f2b4c22f2 // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/sync v0.1.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/config/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (

"github.com/mitchellh/go-homedir"
"github.com/spf13/viper"
"golang.org/x/exp/slices"

"github.com/golangci/golangci-lint/pkg/exitcodes"
"github.com/golangci/golangci-lint/pkg/fsutils"
"github.com/golangci/golangci-lint/pkg/logutils"
"github.com/golangci/golangci-lint/pkg/sliceutil"
)

type FileReader struct {
Expand Down Expand Up @@ -203,7 +203,7 @@ func (r *FileReader) setupConfigFileSearch() {
// find home directory for global config
if home, err := homedir.Dir(); err != nil {
r.log.Warnf("Can't get user's home directory: %s", err.Error())
} else if !sliceutil.Contains(configSearchPaths, home) {
} else if !slices.Contains(configSearchPaths, home) {
configSearchPaths = append(configSearchPaths, home)
}

Expand Down
17 changes: 0 additions & 17 deletions pkg/sliceutil/sliceutil.go

This file was deleted.

17 changes: 0 additions & 17 deletions pkg/sliceutil/sliceutil_test.go

This file was deleted.

14 changes: 3 additions & 11 deletions test/enabled_linters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"strings"
"testing"

"golang.org/x/exp/slices"

"github.com/golangci/golangci-lint/pkg/lint/lintersdb"
"github.com/golangci/golangci-lint/test/testshared"
)
Expand Down Expand Up @@ -134,16 +136,6 @@ func TestEnabledLinters(t *testing.T) {
}
}

func inSlice(s []string, v string) bool {
for _, sv := range s {
if sv == v {
return true
}
}

return false
}

func getEnabledByDefaultFastLintersExcept(except ...string) []string {
m := lintersdb.NewManager(nil, nil)
ebdl := m.GetAllEnabledByDefaultLinters()
Expand All @@ -153,7 +145,7 @@ func getEnabledByDefaultFastLintersExcept(except ...string) []string {
continue
}

if !inSlice(except, lc.Name()) {
if !slices.Contains(except, lc.Name()) {
ret = append(ret, lc.Name())
}
}
Expand Down