Skip to content

Instantly share code, notes, and snippets.

@kaneshin
Created November 11, 2018 05:39
Show Gist options
  • Save kaneshin/727ac467f9146dd0a251ed94cbe8886d to your computer and use it in GitHub Desktop.
Save kaneshin/727ac467f9146dd0a251ed94cbe8886d to your computer and use it in GitHub Desktop.
package main
import (
"flag"
"fmt"
"net/http"
"os"
)
var (
src = flag.String("url", "", "")
dst = flag.String("d", "", "destination")
)
var redirectPolicyFunc = func(req *http.Request, via []*http.Request) error {
return nil
}
func init() {
flag.Parse()
}
func main() {
client := &http.Client{
CheckRedirect: redirectPolicyFunc,
}
resp, err := client.Get(*src)
if err != nil {
panic(err)
}
defer resp.Body.Close()
u := resp.Request.URL.String()
if u == *dst {
fmt.Println("ok")
os.Exit(0)
}
fmt.Println("ng")
os.Exit(1)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment