Created
December 22, 2021 07:38
-
-
Save kougazhang/158f40e6bfe48cc7bb42ded9230f836c to your computer and use it in GitHub Desktop.
#golang #http
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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