Skip to content

Commit 308b9db

Browse files
committed
feat: update go-exhaustruct to v2 and adapt to API changes
1 parent 76de562 commit 308b9db

File tree

7 files changed

+16
-22
lines changed

7 files changed

+16
-22
lines changed

.golangci.example.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ linters-settings:
290290
# If this list is empty, all structs are tested.
291291
include:
292292
- '.*\.Test'
293-
- 'example\.com/package\.ExampleStruct'
293+
- 'example\.com/package\.ExampleStruct[\d]{1,2}'
294294
# List of regular expressions to exclude struct packages and names from check.
295295
exclude:
296296
- 'cobra\.Command$'

docs/template_data.state

100755100644
File mode changed.

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/Antonboom/nilnil v0.1.0
99
github.com/BurntSushi/toml v1.0.0
1010
github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24
11-
github.com/GaijinEntertainment/go-exhaustruct v1.0.0
11+
github.com/GaijinEntertainment/go-exhaustruct/v2 v2.0.1
1212
github.com/OpenPeeDeeP/depguard v1.1.0
1313
github.com/alexkohler/prealloc v1.0.0
1414
github.com/ashanbrown/forbidigo v1.3.0

go.sum

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/golinters/exhaustruct.go

+8-17
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,23 @@
11
package golinters
22

33
import (
4-
"strings"
5-
6-
"github.com/GaijinEntertainment/go-exhaustruct/pkg/analyzer"
4+
"github.com/GaijinEntertainment/go-exhaustruct/v2/pkg/analyzer"
75
"golang.org/x/tools/go/analysis"
86

97
"github.com/golangci/golangci-lint/pkg/config"
108
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
119
)
1210

1311
func NewExhaustruct(settings *config.ExhaustructSettings) *goanalysis.Linter {
14-
a := analyzer.Analyzer
12+
include, exclude := []string{}, []string{}
1513

16-
var cfg map[string]map[string]interface{}
1714
if settings != nil {
18-
cfg = map[string]map[string]interface{}{
19-
a.Name: {
20-
"include": strings.Join(settings.Include, ","),
21-
"exclude": strings.Join(settings.Exclude, ","),
22-
},
23-
}
15+
include = settings.Include
16+
exclude = settings.Exclude
2417
}
2518

26-
return goanalysis.NewLinter(
27-
a.Name,
28-
a.Doc,
29-
[]*analysis.Analyzer{a},
30-
cfg,
31-
).WithLoadMode(goanalysis.LoadModeTypesInfo)
19+
a := analyzer.MustNewAnalyzer(include, exclude)
20+
21+
return goanalysis.NewLinter(a.Name, a.Doc, []*analysis.Analyzer{a}, nil).
22+
WithLoadMode(goanalysis.LoadModeTypesInfo)
3223
}

test/testdata/configs/exhaustruct.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
linters-settings:
22
exhaustruct:
3-
include: ".*\\.ExhaustructCustom$"
4-
exclude: ".*\\.ExhaustructCustom2"
3+
include:
4+
- .*\.ExhaustructCustom
5+
exclude:
6+
- .*\.ExhaustructCustom[\d]{1,2}

test/testdata/symlink_loop/pkg/subpkg

-1
This file was deleted.

0 commit comments

Comments
 (0)