github.com/nozzle/golangci-lint@v1.49.0-nz3/test/testdata/exhaustivestruct.go (about) 1 //golangcitest:args -Eexhaustivestruct --internal-cmd-test 2 package testdata 3 4 import "time" 5 6 type ExhaustiveStruct struct { 7 A string 8 B int 9 c bool // private field inside the same package are not ignored 10 D float64 11 E time.Time 12 } 13 14 func exhaustiveStruct() { 15 // pass 16 _ = ExhaustiveStruct{ 17 A: "a", 18 B: 0, 19 c: false, 20 D: 1.0, 21 E: time.Now(), 22 } 23 24 // failPrivate 25 _ = ExhaustiveStruct{ // want "c is missing in ExhaustiveStruct" 26 A: "a", 27 B: 0, 28 D: 1.0, 29 E: time.Now(), 30 } 31 32 // fail 33 _ = ExhaustiveStruct{ // want "B is missing in ExhaustiveStruct" 34 A: "a", 35 c: false, 36 D: 1.0, 37 E: time.Now(), 38 } 39 40 // failMultiple 41 _ = ExhaustiveStruct{ // want "B, D are missing in ExhaustiveStruct" 42 A: "a", 43 c: false, 44 E: time.Now(), 45 } 46 }