by Mogzol · 1y ago · 0 comments
The link (https://go.dev/talks/2014/names.slide#14) says:
Error values should be of the form ErrFoo:
var ErrFormat = errors.New("image: unknown format")
But the page says: // But if you want to give it a longer name, use "somethingError".
var specificError error
result, specificError = doSpecificThing()
And also says: Don't do this:
[...]
var errSpecific error
result, errSpecific = doSpecificThing()
So should error variables written like `errSpecific` or `specificError`? The go wiki says they should be written starting with `err`: https://go.dev/wiki/Errors#namingThe article, on the other hand, advocates for local variables storing errors not to have distinct names.
And I'm only asking about when you are giving an error a distinct name, not just naming it 'err'.