4 ms·
You should never match against "err.Error()" for conditional error handling, a better solution is to use a custom error type. There are a bunch of different way
by arp242 6y ago
You should never match against "err.Error()" for conditional error handling, a better solution is to use a custom error type. There are a bunch of different ways to approach this in Go.
- julvo 6y agoAh that's better, thanks. here a link for others who are reading this https://gobyexample.com/errors https://gobyexample.com/errors
- apta 6y agoExcept most libraries do nothing of the sort, so you end up having to do a substring search.
- arp242 6y agoI've rarely run in to this, but if you do then I'd expect most people will be happy to accept a PR.
- deleted 6y ago[deleted]