github.com/april1989/origin-go-tools@v0.0.32/cmd/guru/testdata/src/whicherrs/main.go (about) 1 package main 2 3 type errType string 4 5 const constErr errType = "blah" 6 7 func (et errType) Error() string { 8 return string(et) 9 } 10 11 var errVar error = errType("foo") 12 13 func genErr(i int) error { 14 switch i { 15 case 0: 16 return constErr 17 case 1: 18 return errVar 19 default: 20 return nil 21 } 22 } 23 24 func unreachable() { 25 err := errVar // @whicherrs func-dead "err" 26 _ = err 27 } 28 29 func main() { 30 err := genErr(0) // @whicherrs localerrs "err" 31 _ = err 32 }