title: Go checking for the type of a custom Error
body: <p>I am having a hard time using a custom Error type in Go.
  I read this <a href="http://blog.golang.org/error-handling-and-go" rel="noreferrer">Blog post on Errors</a></p>
  
  <p>So I tried this:</p>
  
  <p>In my model.go I defined a custom error:</p>
  
  <pre><code>type ModelMissingError struct {
      msg string // description of error
  }
  
  func (e *ModelMissingError) Error() string { return e.msg }
  </code></pre>
  
  <p>In one of my methods I throw a custom error like this:</p>
  
  <pre><code>...
  return Model{}, &amp;ModelMissingError{"no model found for id"}
  ...
  </code></pre>
  
  <p>In the caller of that method I would like to check the error returned for its type and take action if it is in fact a <code>ModelMissingError</code>. </p>
  
  <p><strong>How can I do this?</strong></p>
  
  <p>I tried this:</p>
  
  <pre><code>if err == model.ModelMissingError 
  </code></pre>
  
  <p>The result is <code>*type model.ModelMissingError is not an expression*</code></p>
  
  <p>Clearly I am missing something. </p>