diff --git a/.golangci.yml b/.golangci.yml index 17860c7..2828261 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -44,7 +44,11 @@ linters-settings: - standard # Captures all standard packages if they do not match another section. - default # Contains all imports that could not be matched to another section type. - prefix(github.com/daixiang0/gci) # Groups all imports with the specified Prefix. - + gocritic: + disable-all: true + enabled-checks: + # suggest removing unnecessary strings.Compare + - stringsCompare gofmt: # simplify code: gofmt with `-s` option, true by default simplify: true @@ -56,6 +60,7 @@ linters-settings: linters: disable-all: true enable: + - gocritic - gofmt - gofumpt - goimports diff --git a/pkg/parse/parse.go b/pkg/parse/parse.go index e8532f8..34eb84e 100644 --- a/pkg/parse/parse.go +++ b/pkg/parse/parse.go @@ -22,11 +22,11 @@ func (l ImportList) Len() int { } func (l ImportList) Less(i, j int) bool { - if strings.Compare(l[i].Path, l[j].Path) == 0 { - return strings.Compare(l[i].Name, l[j].Name) < 0 + if l[i].Path == l[j].Path { + return l[i].Name < l[j].Name } - return strings.Compare(l[i].Path, l[j].Path) < 0 + return l[i].Path < l[j].Path } func (l ImportList) Swap(i, j int) { l[i], l[j] = l[j], l[i] }