Sentinel Errors
The errors.New() function in emperror.dev/errors package includes context information, like stack traces. This means that if you were to use this for sentinel error types, i.e. error types like EOL, you'll be including unnecessary stack information. This is especially useless when these are defined as global variables:
Instead, use the errors.Sentinal type.
Dave Cheney discusses why this works. He also mentions that sentinel errors should be avoided altogether. Not sure I fully agree with him on this.
Last updated