3 ms·
Errors in Go are custom types; your error can be defined as, for example: type URLError { url String } func (e URLError) Error() String {
by azernik 13y ago
Errors in Go are custom types; your error can be defined as, for example:
type URLError {
url String
}
func (e URLError) Error() String {
return fmt.Sprintf("Invalid URL: %s", e.url)
}
At which point a caller that wants to handle this error can either extract the URL to do fun things with it or just dump the Error() string.