package models import ( "database/sql" ) type notFoundError struct { error } func (e *notFoundError) NotFound() bool { return true } // IsNotFoundError returns true if the model deems it a not found error. func IsNotFoundError(err error) bool { type notFound interface { NotFound() bool } te, ok := err.(notFound) return ok && te.NotFound() } func wrapNotFound(err error) error { if err == sql.ErrNoRows { return ¬FoundError{error: err} } return err }