title: Parsing remote json in Go
body: <p>So basically, I'm trying to parse a JSON and assign its values to a struct. I get no errors when I run this, but the returned struct yeilds {0 0 0} which is incorrect. I tried putting in a fake url to see if there was just a connection issue, but that doesn't seem to be the case.</p>
  
  <p>Since Go isn't asynchronous, there shouldn't be a problem with just calling things sequentially, right?</p>
  
  <p>Here's the JSON I hosted on some site</p>
  
  <pre><code>{"ability":5335,"time":338,"level":1}
  </code></pre>
  
  <p>Here's the code</p>
  
  <pre><code>package main
  
  import (
      "encoding/json"
      "fmt"
      "io/ioutil"
      "net/http"
  )
  
  type prog struct {
      ability int64
      time    int64
      level   int64
  }
  
  func main() {
      url := "https://api.myjson.com/bins/2c54h"
  
      //get the data from the url
      res, err := http.Get(url)
      //error handling
      defer res.Body.Close()
  
      if err != nil {
          panic(err)
      }
  
      // read json response
      data, err := ioutil.ReadAll(res.Body)
      // error handling
      var jsonData prog
      err = json.Unmarshal([]byte(data), &amp;jsonData)
  
      if err != nil {
          panic(err)
      }
  
      //test struct data
      fmt.Println(jsonData)
  }
  </code></pre>
  
  <p>The JSON is <a href="https://api.myjson.com/bins/2c54h" rel="nofollow">here</a></p>