Skip to content

Instantly share code, notes, and snippets.

@s-aska

s-aska/longurl.go

Created Mar 3, 2016
Embed
What would you like to do?
🔫 Don't redirect !!!
package main
import(
"errors"
"fmt"
"net/http"
)
var RedirectAttemptedError = errors.New("redirect")
var nopasteClient = func() (*http.Client) {
var client = &http.Client{}
client.CheckRedirect = func(req *http.Request, via []*http.Request) error {
return RedirectAttemptedError
}
return client
}()
func main() {
resp, _ := nopasteClient.Get("https://goo.gl/xqt7hT")
url, _ := resp.Location()
if url != nil {
fmt.Println(url.String())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.