Skip to content

Commit c7b50f6

Browse files
alexandearldez
andauthored
dev: replace sliceutil package with exp/slices (#3830)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
1 parent aad2e22 commit c7b50f6

File tree

6 files changed

+8
-50
lines changed

6 files changed

+8
-50
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ require (
113113
github.com/ykadowak/zerologlint v0.1.1
114114
gitlab.com/bosi/decorder v0.2.3
115115
go.tmz.dev/musttag v0.6.1
116+
golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea
116117
golang.org/x/tools v0.8.0
117118
gopkg.in/yaml.v3 v3.0.1
118119
honnef.co/go/tools v0.4.3
@@ -182,7 +183,6 @@ require (
182183
go.uber.org/atomic v1.7.0 // indirect
183184
go.uber.org/multierr v1.6.0 // indirect
184185
go.uber.org/zap v1.24.0 // indirect
185-
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect
186186
golang.org/x/exp/typeparams v0.0.0-20230224173230-c95f2b4c22f2 // indirect
187187
golang.org/x/mod v0.10.0 // indirect
188188
golang.org/x/sync v0.1.0 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/config/reader.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ import (
99

1010
"github.com/mitchellh/go-homedir"
1111
"github.com/spf13/viper"
12+
"golang.org/x/exp/slices"
1213

1314
"github.com/golangci/golangci-lint/pkg/exitcodes"
1415
"github.com/golangci/golangci-lint/pkg/fsutils"
1516
"github.com/golangci/golangci-lint/pkg/logutils"
16-
"github.com/golangci/golangci-lint/pkg/sliceutil"
1717
)
1818

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

pkg/sliceutil/sliceutil.go

Lines changed: 0 additions & 17 deletions
This file was deleted.

pkg/sliceutil/sliceutil_test.go

Lines changed: 0 additions & 17 deletions
This file was deleted.

test/enabled_linters_test.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66
"strings"
77
"testing"
88

9+
"golang.org/x/exp/slices"
10+
911
"github.com/golangci/golangci-lint/pkg/lint/lintersdb"
1012
"github.com/golangci/golangci-lint/test/testshared"
1113
)
@@ -134,16 +136,6 @@ func TestEnabledLinters(t *testing.T) {
134136
}
135137
}
136138

137-
func inSlice(s []string, v string) bool {
138-
for _, sv := range s {
139-
if sv == v {
140-
return true
141-
}
142-
}
143-
144-
return false
145-
}
146-
147139
func getEnabledByDefaultFastLintersExcept(except ...string) []string {
148140
m := lintersdb.NewManager(nil, nil)
149141
ebdl := m.GetAllEnabledByDefaultLinters()
@@ -153,7 +145,7 @@ func getEnabledByDefaultFastLintersExcept(except ...string) []string {
153145
continue
154146
}
155147

156-
if !inSlice(except, lc.Name()) {
148+
if !slices.Contains(except, lc.Name()) {
157149
ret = append(ret, lc.Name())
158150
}
159151
}

0 commit comments

Comments
 (0)