4 ms·
I differ with the author here, I prefer to log errors as soon as they come into "my" code (e.g. from external library or network call, etc.). This is a good ru
by liampulles 3y ago
I differ with the author here, I prefer to log errors as soon as they come into "my" code (e.g. from external library or network call, etc.).
This is a good rule for any language, because you always ensure an error is logged once. In Go, you can add additional info from the caller to the Context to log higher level info, e.g. a trace span Id.
- preseinger 3y agoan error should be handled in precisely one way - logged (and control flow continues) - returned (and control flow returns) - managed (and control flow (probably) continues) if you log an error, then you should not return it if you return an error, then you should not log it etc.