package mainimport ( "fmt" "log" "net/http")func main() { resp, err := http.Get("http://stackoverflow.com/q/16784419/727643") if err != nil { log.Fatalf("http.Get => %v", err.Error()) } // Your magic function. The Request in the Response is the last URL the // client tried to access. finalURL := resp.Request.URL.String() fmt.Printf("The URL you ended up at is: %vn", finalURL)}输出:
The URL you ended up at is: http://stackoverflow.com/questions/16784419/in-golang-how-to-determine-the-final-url-after-a-series-of-redirects



