3 ms·
Sadly Go doesn't force you to handle the error (this passes go vet): a, err := strconv.Atoi("blah") b, err := strconv.Atoi("123") if err != nil {
by skitter 3y ago
Sadly Go doesn't force you to handle the error (this passes go vet):
a, err := strconv.Atoi("blah")
b, err := strconv.Atoi("123")
if err != nil {
log.Fatal(err)
}
return a + b
This could be fixed to emit a vet error, but ultimately it is inferior to only returning either error or success, instead of returning both even through logically only one exists.
- majewsky 3y agoNot to take away from your argument, but for what it's worth, there is a lint for this [1] which is available in golangci-lint [2]. If there is any Go developer reading this who does not know about golangci-lint, I wholeheartedly recommend looking into it. It's found a fair share of significant issues for me that otherwise would have required tests to uncover. [1] https://github.com/gordonklaus/ineffassign https://github.com/gordonklaus/ineffassign [2] https://golangci-lint.run/ https://golangci-lint.run/