Skip to content

Commit 8ca6e3c

Browse files
committed
Gci: fix panic
Signed-off-by: Xiang Dai <[email protected]>
1 parent cae1842 commit 8ca6e3c

File tree

4 files changed

+37
-3
lines changed

4 files changed

+37
-3
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/Djarvur/go-err113 v0.0.0-20200511133814-5174e21577d5
77
github.com/OpenPeeDeeP/depguard v1.0.1
88
github.com/bombsimon/wsl/v3 v3.1.0
9-
github.com/daixiang0/gci v0.0.0-20200727065011-66f1df783cb2
9+
github.com/daixiang0/gci v0.2.1
1010
github.com/denis-tingajkin/go-header v0.3.1
1111
github.com/fatih/color v1.9.0
1212
github.com/go-critic/go-critic v0.5.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7
4646
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
4747
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
4848
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
49-
github.com/daixiang0/gci v0.0.0-20200727065011-66f1df783cb2 h1:3Lhhps85OdA8ezsEKu+IA1hE+DBTjt/fjd7xNCrHbVA=
50-
github.com/daixiang0/gci v0.0.0-20200727065011-66f1df783cb2/go.mod h1:+AV8KmHTGxxwp/pY84TLQfFKp2vuKXXJVzF3kD/hfR4=
49+
github.com/daixiang0/gci v0.2.1 h1:NKECbLOZsPCh/38vDmWQfYK+rxoFE9EgizSb0SMIt3U=
50+
github.com/daixiang0/gci v0.2.1/go.mod h1:+AV8KmHTGxxwp/pY84TLQfFKp2vuKXXJVzF3kD/hfR4=
5151
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
5252
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
5353
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=

test/linters_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,22 @@ func TestGciLocal(t *testing.T) {
9999
ExpectHasIssue("testdata/gci/gci.go:8: File is not `gci`-ed")
100100
}
101101

102+
func TestGciPanic(t *testing.T) {
103+
sourcePath := filepath.Join(testdataDir, "gci", "panic.go")
104+
args := []string{
105+
"--disable-all", "--print-issued-lines=false", "--print-linter-name=false", "--out-format=line-number",
106+
sourcePath,
107+
}
108+
rc := extractRunContextFromComments(t, sourcePath)
109+
args = append(args, rc.args...)
110+
111+
cfg, err := yaml.Marshal(rc.config)
112+
assert.NoError(t, err)
113+
114+
testshared.NewLintRunner(t).RunWithYamlConfig(string(cfg), args...).
115+
ExpectHasIssue("testdata/gci/panic.go:8: File is not `gci`-ed")
116+
}
117+
102118
func saveConfig(t *testing.T, cfg map[string]interface{}) (cfgPath string, finishFunc func()) {
103119
f, err := ioutil.TempFile("", "golangci_lint_test")
104120
assert.NoError(t, err)

test/testdata/gci/panic.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//args: -Egci
2+
//config: linters-settings.gci.local-prefixes=github.com/golangci/golangci-lint
3+
package gci
4+
5+
import (
6+
"fmt"
7+
8+
"github.com/golangci/golangci-lint/pkg/config"
9+
10+
"github.com/pkg/errors"
11+
//fmt
12+
)
13+
14+
func GoimportsLocalTest() {
15+
fmt.Print("x")
16+
_ = config.Config{}
17+
_ = errors.New("")
18+
}

0 commit comments

Comments
 (0)