golangci-lint/test/testdata/gochecksumtype.go
Alec Thomas 69d6cc93cb
feat: add gochecksumtype linter (#3671)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2023-10-09 17:37:47 +02:00

39 lines
652 B
Go

//golangcitest:args -Egochecksumtype
package testdata
import (
"log"
)
//sumtype:decl
type SumType interface{ isSumType() }
//sumtype:decl
type One struct{} // want "type 'One' is not an interface"
func (One) isSumType() {}
type Two struct{}
func (Two) isSumType() {}
func sumTypeTest() {
var sum SumType = One{}
switch sum.(type) { // want "exhaustiveness check failed for sum type.*SumType.*missing cases for Two"
case One:
}
switch sum.(type) { // want "exhaustiveness check failed for sum type.*SumType.*missing cases for Two"
case One:
default:
panic("??")
}
log.Println("??")
switch sum.(type) {
case One:
case Two:
}
}