staticcheck/sa4023/testdata/go1.0/i27815/27815.go
raw| 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | ) |
| 6 | |
| 7 | type MyError struct { |
| 8 | x string |
| 9 | } |
| 10 | |
| 11 | func (e *MyError) Error() string { |
| 12 | return e.x |
| 13 | } |
| 14 | |
| 15 | func f() *MyError { |
| 16 | return nil |
| 17 | } |
| 18 | |
| 19 | func main() { |
| 20 | var e error |
| 21 | e = f() |
| 22 | // e should be nil ? |
| 23 | if e != nil { //@ diag(`this comparison is always true`) |
| 24 | fmt.Println("NOT NIL") |
| 25 | } else { |
| 26 | fmt.Println("NIL") |
| 27 | } |
| 28 | } |