title: Overriding errors.Is() not working with custom errors
body: <p>I am trying to create a custom error in Go such that I can create new instances of that error with a custom message, and then handle that specific type of error. However, when I try to do this, then my overridden <code>errors.Is()</code> is not being executed. Here is my code:</p>
  <pre><code>package main
  
  import (
          &quot;fmt&quot;
          &quot;errors&quot;
  )
  
  type Error struct {
          Message string
          Code int
  }
  
  func (e *Error) Error() string {
          return e.Message
  }
  
  func (e Error) Is(target Error) bool {
          // This is never printed - this method never excutes for some reason
          fmt.Println(&quot;compared!&quot;)
          return e.Code == target.Code
  }
  
  var NotFoundError *Error = &amp;Error{Code: 404, Message: &quot;The page was not found&quot;}
  
  func NewError(errorType *Error, message string) error {
          rc := *errorType
          rc.Message = message
  
          return &amp;rc
  }
  
  func FetchImage() error {
          return NewError(NotFoundError, &quot;That image is gone&quot;)
  }
  
  func main() {
          err := FetchImage()
  
          // Returns false
          fmt.Println(errors.Is(err, NotFoundError))
  }
  </code></pre>
  <p>In this case, the call to <code>errors.Is()</code> returns false. However, even though I have supplied my own Is() function, that function is not being called at all. That is, the string <code>&quot;compared!&quot;</code> is never printed.</p>
  <p>Why isn't my Is() function working as desired?</p>