Skip to content

Instantly share code, notes, and snippets.

@kougazhang
Created December 22, 2021 07:38
Show Gist options
  • Save kougazhang/158f40e6bfe48cc7bb42ded9230f836c to your computer and use it in GitHub Desktop.
Save kougazhang/158f40e6bfe48cc7bb42ded9230f836c to your computer and use it in GitHub Desktop.
#golang #http
// request https
// disable security checks globally for all requests of the default client
func main() {
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
_, err := http.Get("https://golang.org/")
if err != nil {
fmt.Println(err)
}
}
// disable security check for a client
func main() {
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
client := &http.Client{Transport: tr}
_, err := client.Get("https://golang.org/")
if err != nil {
fmt.Println(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment