github.com/vanstinator/golangci-lint@v0.0.0-20240223191551-cc572f00d9d1/test/testdata/gochecksumtype.go (about) 1 //golangcitest:args -Egochecksumtype 2 package testdata 3 4 import ( 5 "log" 6 ) 7 8 //sumtype:decl 9 type SumType interface{ isSumType() } 10 11 //sumtype:decl 12 type One struct{} // want "type 'One' is not an interface" 13 14 func (One) isSumType() {} 15 16 type Two struct{} 17 18 func (Two) isSumType() {} 19 20 func sumTypeTest() { 21 var sum SumType = One{} 22 switch sum.(type) { // want "exhaustiveness check failed for sum type.*SumType.*missing cases for Two" 23 case One: 24 } 25 26 switch sum.(type) { // want "exhaustiveness check failed for sum type.*SumType.*missing cases for Two" 27 case One: 28 default: 29 panic("??") 30 } 31 32 log.Println("??") 33 34 switch sum.(type) { 35 case One: 36 case Two: 37 } 38 }