File tree 5 files changed +42
-3
lines changed
5 files changed +42
-3
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ require (
32
32
github.com/maratori/testpackage v1.0.1
33
33
github.com/matoous/godox v0.0.0-20190911065817-5d6d842e92eb // v1.0
34
34
github.com/mattn/go-colorable v0.1.8
35
+ github.com/mbilski/exhaustivestruct v1.0.1
35
36
github.com/mitchellh/go-homedir v1.1.0
36
37
github.com/mitchellh/go-ps v1.0.0
37
38
github.com/moricho/tparallel v0.2.1
@@ -61,7 +62,7 @@ require (
61
62
github.com/ultraware/whitespace v0.0.4
62
63
github.com/uudashr/gocognit v1.0.1
63
64
github.com/valyala/quicktemplate v1.6.3
64
- golang.org/x/tools v0.0.0-20200918232735-d647fc253266
65
+ golang.org/x/tools v0.0.0-20201001104356-43ebab892c4c
65
66
gopkg.in/yaml.v2 v2.3.0
66
67
honnef.co/go/tools v0.0.1-2020.1.6
67
68
mvdan.cc/gofumpt v0.0.0-20200802201014-ab5a8192947d
Original file line number Diff line number Diff line change
1
+ package golinters
2
+
3
+ import (
4
+ "github.com/mbilski/exhaustivestruct/pkg/analyzer"
5
+ "golang.org/x/tools/go/analysis"
6
+
7
+ "github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
8
+ )
9
+
10
+ func NewExhaustiveStruct () * goanalysis.Linter {
11
+ return goanalysis .NewLinter (
12
+ "exhaustivestruct" ,
13
+ "Checks if all struct's fields are initialized" ,
14
+ []* analysis.Analyzer {analyzer .Analyzer },
15
+ nil ,
16
+ ).WithLoadMode (goanalysis .LoadModeTypesInfo )
17
+ }
Original file line number Diff line number Diff line change @@ -317,6 +317,9 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
317
317
WithPresets (linter .PresetStyle ).
318
318
WithLoadForGoAnalysis ().
319
319
WithURL ("https://github.com/moricho/tparallel" ),
320
+ linter .NewConfig (golinters .NewExhaustiveStruct ()).
321
+ WithPresets (linter .PresetStyle ).
322
+ WithURL ("https://github.com/mbilski/exhaustivestruct" ),
320
323
linter .NewConfig (golinters .NewErrorLint (errorlintCfg )).
321
324
WithPresets (linter .PresetBugs ).
322
325
WithLoadForGoAnalysis ().
Original file line number Diff line number Diff line change
1
+ //args: -Eexhaustivestruct
2
+ package testdata
3
+
4
+ type Test struct {
5
+ A string
6
+ B int
7
+ }
8
+
9
+ var pass = Test {
10
+ A : "a" ,
11
+ B : 0 ,
12
+ }
13
+
14
+ var fail = Test { // ERROR "B is missing in Test"
15
+ A : "a" ,
16
+ }
You can’t perform that action at this time.
0 commit comments