package main import ( "net/http" "time" ) func main() { timeout := time.Duration(5 * time.Second) transport := &http.Transport{ Dial: (&net.Dialer{ Timeout: timeout, }).Dial, TLSHandshakeTimeout: timeout, } client := &http.Client{ Timeout: timeout, Transport: transport, } resp, err := client.Get("https://www.google.com") }
func main() { proxyURL, err := url.Parse("http://localhost:8080") if err != nil { panic(err) } transport := &http.Transport{ Proxy: http.ProxyURL(proxyURL), } client := &http.Client{ Transport: transport, } resp, err := client.Get("http://www.google.com") }In the above example, we are making a HTTP request using a proxy. The transport is configured with the proxy URL and the HTTP client is configured with the custom transport. The package library for the go net/http Transport is "net/http".