title: Do I need to add nil check after decoding a pointer value with the json package?
body: <p>I have been writing in Go for a long time and recently while rewriting the code I came across a strange thing. I did a couple of tests and <code>if request == nil</code> check never worked. Previously, I was always afraid of getting a <code>nil</code> pointer exception, and so I inserted checks everywhere. But in this case, the <code>json</code> decode error handler seems to cover all cases.</p>
  <pre><code>    var (
          request *models.Owner
          err     error
      )
  
      err = json.NewDecoder(r.Body).Decode(&amp;request)
      if err != nil {
          render.Render(w, r, response.ErrInvalidRequest(err))
          return
      }
  
      if request == nil {
          render.Render(w, r, response.ErrInvalidRequest(&quot;request is nil&quot;))
          return
      }
  </code></pre>
  <p><code>if request == nil</code> is it possible to catch this? Perhaps this check is unnecessary, and if I remove this check in my project, the code will become cleaner.</p>