Spot the bug Go
1
package main
2
3
import "fmt"
4
5
type ParseError struct{ line int }6
7
func (e *ParseError) Error() string { return fmt.Sprintf("line %d", e.line) }8
9
func parse(input string) error {10
var perr *ParseError
11
if input == "" {12
perr = &ParseError{0}13
}
14
return perr
15
}
16
17
func main() {18
err := parse("ok")19
fmt.Println(err == nil) // expected: true, actual: false (!)
20
}