title: How to check for the existence of key in a nested struct
body: <p>I have the following struct</p>
  
  <pre><code>   type GiphyJson struct {
          Type string `json:"type"`
          Data []struct {
              Images struct {
                  Fixed_height struct {
                      Url string `json:"url"`
                  } `json:"fixed_height"`
              } `json:"images"`
          } `json:"data"`
      }
  </code></pre>
  
  <p>and I need to access <code>Data[x].Images.Fixed_height.Url</code>. Ideally I'd like to be able to check for the existence of each of the Properties 'Data, Images, ,Fixed_height' before accessing Url to ensure I don't have a nil pointer exceptions. Since I'm fairly new to the language I was curious what the idiomatic way of doing this would be.</p>
  
  <p>The following is how i'm using the struct.</p>
  
  <pre><code>var err error
  var giphyJson GiphyJson
  keyword = url.QueryEscape(keyword)
  resp, err := http.Get("http://api.giphy.com/v1/gifs/search?q=" + keyword + "&amp;api_key=dc6zaTOxFJmzC&amp;limit=100")
  if err != nil {
      err = errors.New("An error occured trying to contact giphy")
      return "", err
  }
  defer resp.Body.Close()
  bodyBytes, err := ioutil.ReadAll(resp.Body)
  err = json.Unmarshal(bodyBytes, &amp;giphyJson)
  </code></pre>