Spot the bug in the typed nil error

from Error handling
Go 1.27 intermediate 4 min 2 issues to find

Find why the valid input still returns a non-nil error.

Go
type ParseError struct {
    Input string
}

func (e *ParseError) Error() string {
    return "invalid input: " + e.Input
}

func validate(input string) error {
    var parseErr *ParseError
    if input == "" {
        parseErr = &ParseError{Input: input}
    }
    return parseErr
}
Open in playground
Report an error