Last active
July 7, 2025 15:07
-
-
Save Integralist/8a9cb8924f75ae42487fd877b03360e2 to your computer and use it in GitHub Desktop.
Revisions
-
Integralist revised this gist
Jul 7, 2025 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -4,10 +4,14 @@ > [!TIP] > Use `context.WithTimeout` when you need to enforce timeouts on internal operations like database queries or HTTP calls, especially when you want to propagate cancellation signals through the call stack to prevent resource leaks or manage goroutines. It's ideal for fine-grained control within a handler. In contrast, use `http.TimeoutHandler` when you want a simple way to enforce a timeout on the entire HTTP handler response, particularly when you don’t control the handler logic or don’t need to cancel ongoing work—it only cuts off the response after the timeout but doesn’t stop the underlying processing. > [!WARNING] > Be careful when using `http.TimeoutHander`. If automatically applied to all handlers (as part of a middleware pipeline) then it will not work when it comes to a streaming endpoint (see the relevant Cloudflare article linked in the NOTE below). **Client Timeouts**\  > [!NOTE] > Read the following articles:\ > [Resilient HTTP servers using timeouts](https://ieftimov.com/posts/make-resilient-golang-net-http-servers-using-timeouts-deadlines-context-cancellation/)\ > [Guide to `net/http` timeouts](https://blog.cloudflare.com/the-complete-guide-to-golang-net-http-timeouts/)\ > Also, [here](https://github.com/hashicorp/go-cleanhttp/blob/master/cleanhttp.go#L22-L42) are some Transport settings you might want. -
Integralist revised this gist
Jul 7, 2025 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -8,6 +8,7 @@  > [!NOTE] > [Resilient HTTP servers using timeouts](https://ieftimov.com/posts/make-resilient-golang-net-http-servers-using-timeouts-deadlines-context-cancellation/)\ > [Guide to `net/http` timeouts](https://blog.cloudflare.com/the-complete-guide-to-golang-net-http-timeouts/)\ > Also, [here](https://github.com/hashicorp/go-cleanhttp/blob/master/cleanhttp.go#L22-L42) are some Transport settings you might want. -
Integralist revised this gist
Jul 7, 2025 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,9 @@ **Server Timeouts**\  > [!TIP] > Use `context.WithTimeout` when you need to enforce timeouts on internal operations like database queries or HTTP calls, especially when you want to propagate cancellation signals through the call stack to prevent resource leaks or manage goroutines. It's ideal for fine-grained control within a handler. In contrast, use `http.TimeoutHandler` when you want a simple way to enforce a timeout on the entire HTTP handler response, particularly when you don’t control the handler logic or don’t need to cancel ongoing work—it only cuts off the response after the timeout but doesn’t stop the underlying processing. **Client Timeouts**\  -
Integralist revised this gist
Jul 7, 2025 . 1 changed file with 7 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,11 @@ **Server Timeouts**\  **Client Timeouts**\  > [!NOTE] > [Guide to `net/http` timeouts](https://blog.cloudflare.com/the-complete-guide-to-golang-net-http-timeouts/)\ > Also, [here](https://github.com/hashicorp/go-cleanhttp/blob/master/cleanhttp.go#L22-L42) are some Transport settings you might want. Although not explicitly stated, DNS resolution appears to be taken into consideration as part of the overall `http.Client.Timeout` setting. If you need to set your own DNS timeout, then it seems https://github.com/miekg/dns is a popular solution. -
Integralist revised this gist
Jul 7, 2025 . No changes.There are no files selected for viewing
-
Integralist revised this gist
May 30, 2025 . No changes.There are no files selected for viewing
-
Integralist revised this gist
May 28, 2025 . No changes.There are no files selected for viewing
-
Integralist revised this gist
Apr 17, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@  > **NOTE:** [Guide to `net/http` timeouts](https://blog.cloudflare.com/the-complete-guide-to-golang-net-http-timeouts/)\ > Also, [here](https://github.com/hashicorp/go-cleanhttp/blob/master/cleanhttp.go#L22-L42) are some Transport settings you might want. Although not explicitly stated, DNS resolution appears to be taken into consideration as part of the overall `http.Client.Timeout` setting. If you need to set your own DNS timeout, then it seems https://github.com/miekg/dns is a popular solution. -
Integralist revised this gist
Apr 17, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@  > **NOTE:** [Guide to `net/http` timeouts](https://blog.cloudflare.com/the-complete-guide-to-golang-net-http-timeouts/)\ > Also, [here]([url](https://github.com/hashicorp/go-cleanhttp/blob/master/cleanhttp.go#L22-L42)) are some Transport settings you might want. Although not explicitly stated, DNS resolution appears to be taken into consideration as part of the overall `http.Client.Timeout` setting. If you need to set your own DNS timeout, then it seems https://github.com/miekg/dns is a popular solution. -
Integralist revised this gist
Apr 17, 2024 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,7 @@  > **NOTE:** [Guide to `net/http` timeouts](https://blog.cloudflare.com/the-complete-guide-to-golang-net-http-timeouts/) > Also, [here]([url](https://github.com/hashicorp/go-cleanhttp/blob/master/cleanhttp.go#L22-L42)) are some Transport settings you might want. Although not explicitly stated, DNS resolution appears to be taken into consideration as part of the overall `http.Client.Timeout` setting. If you need to set your own DNS timeout, then it seems https://github.com/miekg/dns is a popular solution. -
Integralist revised this gist
May 17, 2022 . 2 changed files with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -13,7 +13,7 @@ import ( func main() { client := &http.Client{ Timeout: time.Second * 5, Transport: &http.Transport{ // Avoid: "x509: certificate signed by unknown authority" TLSClientConfig: &tls.Config{ 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 charactersOriginal file line number Diff line number Diff line change @@ -16,7 +16,7 @@ import ( func main() { client := &http.Client{ Timeout: time.Second * 5, Transport: &http.Transport{ // Avoid: "x509: certificate signed by unknown authority" TLSClientConfig: &tls.Config{ -
Integralist revised this gist
May 17, 2022 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -14,7 +14,7 @@ import ( func main() { client := &http.Client{ Timeout: time.Second * 5, Transport: &http.Transport{ // Avoid: "x509: certificate signed by unknown authority" TLSClientConfig: &tls.Config{ -
Integralist revised this gist
Jul 30, 2021 . 1 changed file with 8 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -5,4 +5,11 @@ Although not explicitly stated, DNS resolution appears to be taken into consideration as part of the overall `http.Client.Timeout` setting. If you need to set your own DNS timeout, then it seems https://github.com/miekg/dns is a popular solution. Additionally, it's important to realise how golang resolves hostnames to IPs (i.e. DNS resolution): https://golang.org/pkg/net/#hdr-Name_Resolution When cross-compiling binaries you'll find that CGO is typically disabled in favour of the native Go resolver. You can enforce CGO or native like so: ``` env GODEBUG=netdns=cgo+2 go run main.go env GODEBUG=netdns=go+2 go run main.go ``` -
Integralist revised this gist
Jul 29, 2021 . No changes.There are no files selected for viewing
-
Integralist revised this gist
Jun 3, 2021 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,4 +2,7 @@ > NOTE: [Guide to `net/http` timeouts](https://blog.cloudflare.com/the-complete-guide-to-golang-net-http-timeouts/) Although not explicitly stated, DNS resolution appears to be taken into consideration as part of the overall `http.Client.Timeout` setting. If you need to set your own DNS timeout, then it seems https://github.com/miekg/dns is a popular solution. Additionally, it's important to realise how golang resolves hostnames to IPs (i.e. DNS resolution): https://golang.org/pkg/net/#hdr-Name_Resolution -
Integralist revised this gist
Jun 3, 2021 . 2 changed files with 2 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,6 +2,4 @@ > NOTE: [Guide to `net/http` timeouts](https://blog.cloudflare.com/the-complete-guide-to-golang-net-http-timeouts/) Although not explicitly stated, DNS resolution appears to be taken into consideration as part of the overall `http.Client.Timeout` setting. If you need to set your own DNS timeout, then it seems https://github.com/miekg/dns is a popular solution. 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 charactersOriginal file line number Diff line number Diff line change @@ -38,6 +38,7 @@ func main() { }, } // Also try: https://v4.testmyipv6.com/ req, err := http.NewRequest("GET", "https://ipv4.lookup.test-ipv6.com/", nil) if err != nil { log.Fatal(err) -
Integralist revised this gist
Jun 3, 2021 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -63,6 +63,7 @@ func resolveIPv4(addr string) (string, error) { m.SetQuestion(dns.Fqdn(url[0]), dns.TypeA) m.RecursionDesired = true // NOTE: you shouldn't consult or rely on /etc/resolv.conf as it has proven historically to contain nameservers that don't respond. config, _ := dns.ClientConfigFromFile("/etc/resolv.conf") c := new(dns.Client) r, _, err := c.Exchange(m, net.JoinHostPort(config.Servers[0], config.Port)) -
Integralist revised this gist
Jun 3, 2021 . 2 changed files with 39 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,3 @@ package main import ( @@ -38,7 +36,7 @@ func main() { httpClient := &http.Client{} // Testing the new HTTP client with the custom DNS resolver. resp, err := httpClient.Get("https://www.google.com") if err != nil { log.Fatalln(err) } 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ // This enables you to utilise a package such as https://github.com/miekg/dns to resolve the hostname. package main import ( "context" "io/ioutil" "log" "net" "net/http" "time" ) func main() { dialer := &net.Dialer{ Timeout: 30 * time.Second, KeepAlive: 30 * time.Second, } http.DefaultTransport.(*http.Transport).DialContext = func(ctx context.Context, network, addr string) (net.Conn, error) { if addr == "google.com:443" { addr = "216.58.198.206:443" } return dialer.DialContext(ctx, network, addr) } resp, err := http.Get("https://www.google.com") if err != nil { log.Fatalln(err) } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { log.Fatalln(err) } log.Println(string(body)) } -
Integralist revised this gist
Jun 3, 2021 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,3 +2,6 @@ > NOTE: [Guide to `net/http` timeouts](https://blog.cloudflare.com/the-complete-guide-to-golang-net-http-timeouts/) Although not explicitly stated, DNS resolution appears to be taken into consideration as part of the overall `http.Client.Timeout` setting. If you need to set your own DNS timeout, then it seems https://github.com/miekg/dns is a popular solution. Also, from what I can tell, it seems although you can configure your own `net.Resolver` (with allows you to pass a ctx, with a timeout, to its various lookup methods), the irony appears to be that the `net.Resolver` is only attachable to `http.Transport` (itself you can only attach that to a custom `http.Client`) but by the time the `http.Transport.DialContext` function is called, go has already internally attempted to resolve the hostname given to `http.Client.Do` and so your instance of the `net.Resolver` would only really be applicable to any _additional_ DNS lookups required. -
Integralist revised this gist
Jun 2, 2021 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ // NOTE: this doesn't override the internal go DNS resolver. It happens after the DNS has been resolved and seemingly proxies it onto another DNS resolver? package main import ( -
Integralist revised this gist
Jun 2, 2021 . 2 changed files with 51 additions and 0 deletions.There are no files selected for viewing
File renamed without changes.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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,51 @@ package main import ( "context" "io/ioutil" "log" "net" "net/http" "time" ) func main() { var ( dnsResolverIP = "8.8.8.8:53" // Google DNS resolver. dnsResolverProto = "udp" // Protocol to use for the DNS resolver dnsResolverTimeoutMs = 5000 // Timeout (ms) for the DNS resolver (optional) ) dialer := &net.Dialer{ Resolver: &net.Resolver{ PreferGo: true, Dial: func(ctx context.Context, network, address string) (net.Conn, error) { d := net.Dialer{ Timeout: time.Duration(dnsResolverTimeoutMs) * time.Millisecond, } return d.DialContext(ctx, dnsResolverProto, dnsResolverIP) }, }, } dialContext := func(ctx context.Context, network, addr string) (net.Conn, error) { return dialer.DialContext(ctx, network, addr) } http.DefaultTransport.(*http.Transport).DialContext = dialContext httpClient := &http.Client{} // Testing the new HTTP client with the custom DNS resolver. resp, err := httpClient.Get("https://www.violetnorth.com") if err != nil { log.Fatalln(err) } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { log.Fatalln(err) } log.Println(string(body)) } -
Integralist renamed this gist
Jun 2, 2021 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Integralist revised this gist
Jun 2, 2021 . 1 changed file with 49 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,49 @@ package main import ( "context" "crypto/tls" "fmt" "io" "log" "net" "net/http" "time" ) func main() { client := &http.Client{ Timeout: time.Second * time.Duration(5*time.Second), Transport: &http.Transport{ // Avoid: "x509: certificate signed by unknown authority" TLSClientConfig: &tls.Config{ InsecureSkipVerify: true, }, DialContext: func(ctx context.Context, network string, addr string) (net.Conn, error) { return (&net.Dialer{}).DialContext(ctx, "tcp4", addr) }, }, } // Fastly's DNS system controls whether we will report IPv6 addresses for a // given hostname, and in the case of developer.fastly.com it CNAMEs to the // Fastly map devhub.fastly.net which is configured to opt-in or out of v6 // support at the map level. The devhub map has dual-stack enabled on it. // Therefore, it will announce v6 addresses for it if a client sends AAAA DNS // queries for the hostname. req, err := http.NewRequest("GET", "https://developer.fastly.com/api/internal/cli-config", nil) if err != nil { log.Fatal(err) } res, err := client.Do(req) if err != nil { log.Fatal(err) } b, err := io.ReadAll(res.Body) if err != nil { log.Fatal(err) } fmt.Printf("%+v\n", string(b)) } -
Integralist revised this gist
Jun 2, 2021 . 1 changed file with 79 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,79 @@ package main import ( "context" "crypto/tls" "fmt" "io" "log" "net" "net/http" "strings" "time" "github.com/miekg/dns" ) func main() { client := &http.Client{ Timeout: time.Second * time.Duration(5*time.Second), Transport: &http.Transport{ // Avoid: "x509: certificate signed by unknown authority" TLSClientConfig: &tls.Config{ InsecureSkipVerify: true, }, DialContext: func(ctx context.Context, network string, addr string) (net.Conn, error) { ipv4, err := resolveIPv4(addr) if err != nil { return nil, err } timeout, err := time.ParseDuration("10s") if err != nil { return nil, err } return (&net.Dialer{ Timeout: timeout, }).DialContext(ctx, network, ipv4) }, }, } req, err := http.NewRequest("GET", "https://ipv4.lookup.test-ipv6.com/", nil) if err != nil { log.Fatal(err) } res, err := client.Do(req) if err != nil { log.Fatal(err) } b, err := io.ReadAll(res.Body) if err != nil { log.Fatal(err) } fmt.Printf("%+v\n", string(b)) } // resolveIPv4 resolves an address to IPv4 address. func resolveIPv4(addr string) (string, error) { url := strings.Split(addr, ":") m := new(dns.Msg) m.SetQuestion(dns.Fqdn(url[0]), dns.TypeA) m.RecursionDesired = true config, _ := dns.ClientConfigFromFile("/etc/resolv.conf") c := new(dns.Client) r, _, err := c.Exchange(m, net.JoinHostPort(config.Servers[0], config.Port)) if err != nil { return "", err } for _, ans := range r.Answer { if a, ok := ans.(*dns.A); ok { url[0] = a.A.String() } } return strings.Join(url, ":"), nil } -
Integralist revised this gist
Jun 2, 2021 . 1 changed file with 20 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,19 +2,34 @@ package main import ( "crypto/tls" "errors" "fmt" "io" "log" "net" "net/http" "syscall" "time" ) func main() { client := &http.Client{ Timeout: time.Second * time.Duration(5*time.Second), Transport: &http.Transport{ // Avoid: "x509: certificate signed by unknown authority" TLSClientConfig: &tls.Config{ InsecureSkipVerify: true, }, // Inspect the network connection type DialContext: (&net.Dialer{ Control: func(network, address string, c syscall.RawConn) error { // Reference: https://golang.org/pkg/net/#Dial if network == "tcp4" { return errors.New("we don't want you to use IPv4") } return nil }, }).DialContext, }, } @@ -28,5 +43,9 @@ func main() { log.Fatal(err) } b, err := io.ReadAll(res.Body) if err != nil { log.Fatal(err) } fmt.Printf("%+v\n", string(b)) } -
Integralist revised this gist
Jun 2, 2021 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@  > NOTE: [Guide to `net/http` timeouts](https://blog.cloudflare.com/the-complete-guide-to-golang-net-http-timeouts/) -
Integralist revised this gist
Jun 2, 2021 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1 +1,4 @@ https://blog.cloudflare.com/the-complete-guide-to-golang-net-http-timeouts/  -
Integralist revised this gist
Jun 2, 2021 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@  -
Integralist created this gist
Jun 2, 2021 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ package main import ( "crypto/tls" "fmt" "log" "net/http" "time" ) func main() { client := &http.Client{ Timeout: time.Second * time.Duration(5*time.Second), Transport: &http.Transport{ TLSClientConfig: &tls.Config{ InsecureSkipVerify: true, }, }, } req, err := http.NewRequest("GET", "https://ipv4.lookup.test-ipv6.com/", nil) if err != nil { log.Fatal(err) } res, err := client.Do(req) if err != nil { log.Fatal(err) } fmt.Printf("%+v\n", res) }