How to retrieve the final URL destination while using the http package in Go? -


most sites redirect url during request. example: http://example.com might might redirects http://mobile.example.com

is there way retrieve final destination? in case of curl, call effective url.

for example,

package main  import (     "fmt"     "net/http" )  func main() {     geturl := "http://pkgdoc.org/"     fmt.println("geturl:", geturl)     resp, err := http.get(geturl)     if err != nil {         fmt.println(err)         return     }     finalurl := resp.request.url.string()     fmt.println("finalurl:", finalurl) } 

output:

geturl: http://pkgdoc.org/ finalurl: http://godoc.org/ 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -