File tree Expand file tree Collapse file tree 5 files changed +42
-3
lines changed Expand file tree Collapse file tree 5 files changed +42
-3
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ require (
3232 github.com/maratori/testpackage v1.0.1
3333 github.com/matoous/godox v0.0.0-20190911065817-5d6d842e92eb // v1.0
3434 github.com/mattn/go-colorable v0.1.8
35+ github.com/mbilski/exhaustivestruct v1.0.1
3536 github.com/mitchellh/go-homedir v1.1.0
3637 github.com/mitchellh/go-ps v1.0.0
3738 github.com/moricho/tparallel v0.2.1
@@ -61,7 +62,7 @@ require (
6162 github.com/ultraware/whitespace v0.0.4
6263 github.com/uudashr/gocognit v1.0.1
6364 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
6566 gopkg.in/yaml.v2 v2.3.0
6667 honnef.co/go/tools v0.0.1-2020.1.6
6768 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 {
317317 WithPresets (linter .PresetStyle ).
318318 WithLoadForGoAnalysis ().
319319 WithURL ("https://github.com/moricho/tparallel" ),
320+ linter .NewConfig (golinters .NewExhaustiveStruct ()).
321+ WithPresets (linter .PresetStyle ).
322+ WithURL ("https://github.com/mbilski/exhaustivestruct" ),
320323 linter .NewConfig (golinters .NewErrorLint (errorlintCfg )).
321324 WithPresets (linter .PresetBugs ).
322325 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