package main import ( "errors" "fmt" ) type SentinelError string func (s SentinelError) Error() string { return string(s) } func (s SentinelError) Is(target error) bool { return s.Error() == target.Error() } const ( ErrId = SentinelError("Wrong ID") ErrTest = SentinelError("Wrong Test") ) func main() { errId := ErrId errTest := ErrTest fmt.Printf("Does ErrId found: %b\n", errors.Is(errId, ErrId)) fmt.Printf("Does ErrTest found: %b\n", errors.Is(errId, ErrTest)) fmt.Printf("Does ErrId found: %b\n", errors.Is(errTest, ErrId)) fmt.Printf("Does ErrTest found: %b\n", errors.Is(errTest, ErrTest)) }