Many functions in go return errors to fit an interface, but these errors are always nil. Should these errors still be checked?
An example for this is the crypto/sha1 Write() function, which does not set the err value. So the code does not need to be:
_, err = sha1Hasher.Write(buffer)
if err != nil {
log.Printf("sha1 could not be calculated (%s)", err)
}
but only:
sha1Hasher.Write(buffer)
The second option is shorter and cleaner and go is a lot about simple code but it is suggested to handle all errors:
But remember: Whatever you do, always check your errors!
https://blog.golang.org/errors-are-values
Clearly, we must handle any errors; we can't just ignore them.
https://stackoverflow.com/a/16126516/4944254
Which is the best way to go?