import "net/http" func main() { tr := &http.Transport{ TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, } client := &http.Client{Transport: tr} resp, err := client.Get("https://example.com") if err != nil { // handle error } // handle response }
import ( "net" "net/http" "time" ) func main() { dialer := &net.Dialer{ Timeout: 5 * time.Second, } tr := &http.Transport{ DialContext: dialer.DialContext, } client := &http.Client{Transport: tr} resp, err := client.Get("https://example.com") if err != nil { // handle error } // handle response }In the above code, the Dialer object is created to set a timeout of 5 seconds for the connection. The DialContext function from the Dialer object is used in the Transport object, which creates a new connection with the specified timeout period. Package Library: The Dial function is a part of the net/http package in Go language.