Configure TrueProxies with Go
Basic Usage
Section titled “Basic Usage”package main
import ( "fmt" "io" "net/http" "net/url")
func main() { proxyURL, _ := url.Parse("http://your_username:your_password@YOUR_HOST:YOUR_HTTP_PORT") client := &http.Client{ Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)}, }
resp, err := client.Get("https://httpbin.org/ip") if err != nil { panic(err) } defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body) fmt.Println(string(body))}package main
import ( "fmt" "io" "net/http"
"golang.org/x/net/proxy")
func main() { auth := proxy.Auth{User: "your_username", Password: "your_password"} dialer, _ := proxy.SOCKS5("tcp", "YOUR_HOST:YOUR_SOCKS_PORT", &auth, proxy.Direct)
client := &http.Client{ Transport: &http.Transport{Dial: dialer.Dial}, }
resp, err := client.Get("https://httpbin.org/ip") if err != nil { panic(err) } defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body) fmt.Println(string(body))}Residential IPv4 country targeting
Section titled “Residential IPv4 country targeting”proxyURL, _ := url.Parse("http://your_username-country-us:your_password@YOUR_HOST:YOUR_HTTP_PORT")client := &http.Client{ Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)},}Residential IPv4 sticky sessions
Section titled “Residential IPv4 sticky sessions”proxyURL, _ := url.Parse("http://your_username-session-abc123:your_password@YOUR_HOST:YOUR_HTTP_PORT")client := &http.Client{ Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)},}With Timeout
Section titled “With Timeout”client := &http.Client{ Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)}, Timeout: 30 * time.Second,}