> Functions that return something are given noun-like names.
> // Good: > func (c Config) JobName(key string) (value string, ok bool)
> A corollary of this is that function and method names should avoid the prefix Get.
> // Bad: > func (c Config) GetJobName(key string) (value string, ok bool)
That's dumb. I'd like a function to be GetJobName to indicate that it doesn't mutate anything. Maybe CreateJobName to indicate mutation. Just JobName is useless.
The other day, I spent a whole day trying to figure out the "idiomatic" way to return a an object not found case from my db. Do you return a nil pointer (don't, passing pointers leads to bugs), or an empty struct (then how do you reliably "test" its emptiness?) or an error? And of course, there's no real hierarchy of errors, no built-in extensible handling of errors that is semantic and makes sense, so every project just goes and reinvents their wheel.