title: Golang: Getting the response-redirect URL from an HTTP response
body: <p>I'm trying to make a HTTP request using http.Get(url) in Go and I want to open the response in a browser. I'm using browser.OpenURL() to launch the system browser, but I cannot figure out how to obtain the response url.</p>
  <p>In Python, using the requests library, it is an attribute of the response object.
  I can obtain and open it in a browser (using the browser library) like so:</p>
  <pre><code>response = requests.get(endpoint)
  browser.open(response.url)
  </code></pre>
  <p>How can I accomplish this using http/net library in Go? The response object is a struct that doesn't contain that attribute.</p>
  <p>I am trying to call the Spotify API to authenticate an app, and this requires opening a browser window for user input. So far I've got this:</p>
  <pre><code>func getAuth(endpoint *url.Url) {
      request, _ := http.NewRequest(&quot;GET&quot;, endpoint.string(), nil)
      client := &amp;http.Client{}
      resp, err := client.Do(request)
      if err != nil {
          panic(err)
      }
      headers := resp.Header
      page, _ := ioutil.ReadAll(resp.Body)
  </code></pre>
  <p>Where can I obtain the response URL or how can I handle the response so that it opens it in a browser?</p>