Description
The previous go library had a utility method for checking if an error is a KeyNotFound error [1].
The new library lacks such a method, and one has to do some digging to figure out the solution:
func keyNotFound(err error) bool {
|
if err == nil {
|
return false
|
} else if notFound, ok := err.(interface {
|
KeyNotFound() bool
|
}); !ok {
|
return false
|
} else {
|
return notFound.KeyNotFound()
|
}
|
}
|
It would be great to have a utility method for this idiom in the main pkg. Alternatively it would be great to see more information on error handling in the documentation.
[1] https://godoc.org/github.com/couchbase/gomemcached#IsNotFound