The error variable name should be chosen carefully to convey the meaning of the error. It is recommended to use names like errFoo
, ErrSomethingBad
, ErrKindFoo
or BazError
for error variables that are part of an API.
Examples:
_, e := ioutil.ReadFile("file.txt")
if e != nil {
log.Fatal(e)
}
_, err := ioutil.ReadFile("file.txt")
if err != nil {
log.Fatal(err)
}
Reference: Effective Go - Errors