Skip to content

Commit 2038740

Browse files
committed
chore: goimports.local-prefixes -> slice
1 parent 43b5c05 commit 2038740

File tree

6 files changed

+15
-8
lines changed

6 files changed

+15
-8
lines changed

.golangci.next.reference.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,9 @@ formatters:
400400
goimports:
401401
# A comma-separated list of prefixes, which, if set, checks import paths
402402
# with the given prefixes are grouped after 3rd-party packages.
403-
# Default: ""
404-
local-prefixes: github.com/org/project
403+
# Default: []
404+
local-prefixes:
405+
- github.com/org/project
405406

406407
golines:
407408
# Target maximum line length.

.golangci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ formatters:
114114
- pattern: 'interface{}'
115115
replacement: 'any'
116116
goimports:
117-
local-prefixes: github.com/golangci/golangci-lint
117+
local-prefixes:
118+
- github.com/golangci/golangci-lint
118119

119120
linters-settings:
120121
depguard:

jsonschema/golangci.next.jsonschema.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,8 +1556,10 @@
15561556
"properties": {
15571557
"local-prefixes": {
15581558
"description": "Put imports beginning with prefix after 3rd-party packages. It is a comma-separated list of prefixes.",
1559-
"type": "string",
1560-
"examples": ["github.com/org/project"]
1559+
"type": "array",
1560+
"items": {
1561+
"type": "string"
1562+
}
15611563
}
15621564
}
15631565
},

pkg/config/formatters_settings.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ type GoFumptSettings struct {
5151
}
5252

5353
type GoImportsSettings struct {
54-
LocalPrefixes string `mapstructure:"local-prefixes"`
54+
LocalPrefixes []string `mapstructure:"local-prefixes"`
5555
}
5656

5757
type GoLinesSettings struct {

pkg/goformatters/goimports/goimports.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package goimports
22

33
import (
4+
"strings"
5+
46
"golang.org/x/tools/imports"
57

68
"github.com/golangci/golangci-lint/pkg/config"
@@ -12,7 +14,7 @@ type Formatter struct{}
1214

1315
func New(settings *config.GoImportsSettings) *Formatter {
1416
if settings != nil {
15-
imports.LocalPrefix = settings.LocalPrefixes
17+
imports.LocalPrefix = strings.Join(settings.LocalPrefixes, ",")
1618
}
1719

1820
return &Formatter{}

pkg/golinters/goimports/testdata/goimports_local.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ formatters:
55
- goimports
66
settings:
77
goimports:
8-
local-prefixes: github.com/golangci/golangci-lint
8+
local-prefixes:
9+
- github.com/golangci/golangci-lint

0 commit comments

Comments
 (0)