code: func Fetch(client *http.Client, url url.URL, target interface{}) error {
  	clientLog.Debug("Attempting to request data from ", url.String())
  	req, err := http.NewRequest("GET", url.String(), nil)
  	if err != nil {
  		return err
  	}
  
  	req.Header.Set("User-Agent", USERAGENT)
  
  	resp, err := client.Do(req)
  	if err != nil {
  		return err
  	}
  	defer resp.Body.Close()
  
  	// Special case: on HTTP 401 Unauthorized, exit immediately. Considering this
  	// could be running in a goroutine, we don't want the caller to fail forever.
  	if resp.StatusCode == http.StatusUnauthorized {
  		clientLog.Fatalf("fetch error: unauthorized: please provide a suitable auth token")
  	}
  
  	if resp.StatusCode != http.StatusOK {
  		e := fmt.Errorf("fetch error: %s", resp.Status)
  		clientLog.Error(e)
  		return e
  	}
  
  	b, err := ioutil.ReadAll(resp.Body)
  	if err != nil {
  		e := fmt.Errorf("read error: %s: %v", url.String(), err)
  		clientLog.Error(e)
  		return e
  	}
  
  	if err := json.Unmarshal(b, &target); err != nil {
  		clientLog.Errorf("Failed to unmarshal JSON from %+v", url)
  		return err
  	}
  
  	return nil
  }
docs: // Fetch queries an API endpoint and expects to receive JSON. It then unmarshals
  // the JSON to the interface{} provided by the caller. By returning data this
  // way, Fetch() ensures that JSON is always unmarshaled the same way, and that
  // errors are handled correctly, but allows the returned data to be mapped to
  // an arbitrary struct that the caller is aware of.