title: Golang check if interface type is nil
body: <p>When unmarshalling a string of json, using Golang's <code>json.Unmarshal()</code> function, I always unmarshal the string into a <code>map[string]interface{}</code> - <em>I'm not sure weather there is a more optimal way of decoding json.</em></p>
  
  <p><strong>To get to the point:</strong> </p>
  
  <p>Sometimes the json's unmarshalled type is <code>nil</code>, not <code>string</code> (or <code>int</code> etc.). This always throws a panic, saying:</p>
  
  <blockquote>
    <p>interface conversion: interface is nil, not int</p>
  </blockquote>
  
  <p>How can I avoid this panic or check if the interface's type is <code>nil</code> or not?</p>
  
  <p><strong>Example:</strong></p>
  
  <p>Here is an example of my problem in action: <a href="https://play.golang.org/p/0ATzXBbdoS" rel="nofollow noreferrer">https://play.golang.org/p/0ATzXBbdoS</a></p>