[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"blog-post-en-using-proxies-in-go":3},{"success":4,"payload":5,"related":85,"errors":157},true,{"id":6,"slug":7,"title":8,"excerpt":9,"body_html":10,"meta_title":11,"meta_description":12,"canonical_url":13,"canonical_override":14,"og_title":15,"og_description":16,"og_image_url":17,"faq_json":18,"key_takeaways":34,"allow_index":40,"noindex_google_only":4,"allow_follow":4,"published_at":41,"updated_at":42,"content_updated_at":43,"featured_image_url":44,"featured_image_alt":14,"card_image_url":45,"reading_time_minutes":46,"author":47,"categories":51,"tags":58,"alternates":71,"locale_paths":83,"views":84},6,"using-proxies-in-go","Using Proxies in Go: HTTP Client & SDK Guide","Learn how to configure proxies in Go using net\u002Fhttp and the ProxyHat Go SDK. Covers authentication, rotation, geo-targeting, goroutine concurrency, and production best practices.","\u003Ch2>Why Use Proxies in Go?\u003C\u002Fh2>\n\u003Cp>Go has become the language of choice for high-performance networking tools, web scrapers, and API clients. Its lightweight goroutines, built-in concurrency primitives, and a battle-tested \u003Ccode>net\u002Fhttp\u003C\u002Fcode> standard library make it ideal for proxy-powered applications that need to handle thousands of concurrent requests.\u003C\u002Fp>\n\u003Cp>Whether you are building a \u003Ca href=\"\u002Fuse-cases\u002Fweb-scraping\">web scraping\u003C\u002Fa> pipeline, monitoring \u003Ca href=\"\u002Fuse-cases\u002Fserp-tracking\">SERP rankings\u003C\u002Fa>, or collecting competitive pricing data, routing your Go HTTP clients through proxies lets you rotate IP addresses, bypass geo-restrictions, and avoid rate limits at scale.\u003C\u002Fp>\n\u003Cp>In this guide, you will route Go traffic through ProxyHat with nothing but the standard library, and use the \u003Ca href=\"https:\u002F\u002Fgithub.com\u002FProxyHatCom\u002Fgo-sdk\" rel=\"noopener noreferrer\">ProxyHat Go SDK\u003C\u002Fa> for the account side: looking up location codes and checking sub-user traffic. Every code snippet is copy-paste-ready and was run against the live gateway.\u003C\u002Fp>\n\u003Ch2>Installation\u003C\u002Fh2>\n\u003Ch3>Standard library only\u003C\u002Fh3>\n\u003Cp>Sending requests through the proxy needs nothing beyond Go's \u003Ccode>net\u002Fhttp\u003C\u002Fcode> and \u003Ccode>net\u002Furl\u003C\u002Fcode> packages. No extra installation required.\u003C\u002Fp>\n\u003Ch3>ProxyHat Go SDK\u003C\u002Fh3>\n\u003Cp>The SDK is a client for the ProxyHat account API: sub-users, location codes, usage analytics. It does not send your HTTP requests itself; your traffic always goes through \u003Ccode>net\u002Fhttp\u003C\u002Fcode> as shown below.\u003C\u002Fp>\n\u003Cpre>\u003Ccode>go get github.com\u002FProxyHatCom\u002Fgo-sdk\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Ch2>Authentication and Basic Setup\u003C\u002Fh2>\n\u003Cp>ProxyHat uses username-password authentication over the proxy endpoint. You will find your sub-user's proxy credentials in the ProxyHat dashboard (see the \u003Ca href=\"https:\u002F\u002Fdocs.proxyhat.com\u002F\" rel=\"noopener noreferrer\">documentation\u003C\u002Fa> for details). A typical proxy URL looks like this:\u003C\u002Fp>\n\u003Cpre>\u003Ccode>http:\u002F\u002FUSERNAME:PASSWORD@gate.proxyhat.com:8080\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>Keep credentials out of source code. Use environment variables or a \u003Ccode>.env\u003C\u002Fcode> file:\u003C\u002Fp>\n\u003Cpre>\u003Ccode>export PROXYHAT_USER=\"your_username\"\nexport PROXYHAT_PASS=\"your_password\"\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Ch2>Simple GET Request with a Proxy\u003C\u002Fh2>\n\u003Cp>Here is the minimal approach using only the standard library:\u003C\u002Fp>\n\u003Cpre>\u003Ccode>package main\nimport (\n    \"fmt\"\n    \"io\"\n    \"log\"\n    \"net\u002Fhttp\"\n    \"net\u002Furl\"\n    \"os\"\n)\nfunc main() {\n    proxyURL, err := url.Parse(fmt.Sprintf(\n        \"http:\u002F\u002F%s:%s@gate.proxyhat.com:8080\",\n        os.Getenv(\"PROXYHAT_USER\"),\n        os.Getenv(\"PROXYHAT_PASS\"),\n    ))\n    if err != nil {\n        log.Fatal(err)\n    }\n    client := &http.Client{\n        Transport: &http.Transport{\n            Proxy: http.ProxyURL(proxyURL),\n        },\n    }\n    resp, err := client.Get(\"https:\u002F\u002Fhttpbin.org\u002Fip\")\n    if err != nil {\n        log.Fatal(err)\n    }\n    defer resp.Body.Close()\n    body, _ := io.ReadAll(resp.Body)\n    fmt.Println(string(body))\n}\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>Run it and you will see a residential IP address instead of your own. Every request is routed through ProxyHat's \u003Ca href=\"\u002Fblog\u002Fresidential-vs-datacenter-vs-mobile-proxies\">residential proxy pool\u003C\u002Fa>.\u003C\u002Fp>\n\u003Ch2>Using Different Proxy Types\u003C\u002Fh2>\n\u003Cp>ProxyHat supports two rotating proxy types (datacenter is coming soon), each suited to different workloads. You select the type with a username flag on the same port (residential is the default):\u003C\u002Fp>\n\u003Ctable>\n\u003Ccaption>Using Different Proxy Types\u003C\u002Fcaption>\n\u003Cthead>\n\u003Ctr>\u003Cth>Type\u003C\u002Fth>\u003Cth>Username flag\u003C\u002Fth>\u003Cth>Best For\u003C\u002Fth>\u003Cth>Avg Latency\u003C\u002Fth>\u003C\u002Ftr>\n\u003C\u002Fthead>\n\u003Ctbody>\n\u003Ctr>\u003Ctd>Residential\u003C\u002Ftd>\u003Ctd>none (default)\u003C\u002Ftd>\u003Ctd>Web scraping, ad verification\u003C\u002Ftd>\u003Ctd>~800 ms\u003C\u002Ftd>\u003C\u002Ftr>\n\u003Ctr>\u003Ctd>Datacenter\u003C\u002Ftd>\u003Ctd>coming soon\u003C\u002Ftd>\u003Ctd>High-speed bulk requests\u003C\u002Ftd>\u003Ctd>~200 ms\u003C\u002Ftd>\u003C\u002Ftr>\n\u003Ctr>\u003Ctd>Mobile\u003C\u002Ftd>\u003Ctd>\u003Ccode>-type-mobile\u003C\u002Fcode>\u003C\u002Ftd>\u003Ctd>Social media, app testing\u003C\u002Ftd>\u003Ctd>~1200 ms\u003C\u002Ftd>\u003C\u002Ftr>\n\u003C\u002Ftbody>\n\u003C\u002Ftable>\n\u003Cp>For a deeper comparison of when to use each type, see our guide on \u003Ca href=\"\u002Fblog\u002Fresidential-vs-datacenter-vs-mobile-proxies\">residential vs datacenter vs mobile proxies\u003C\u002Fa>.\u003C\u002Fp>\n\u003Cpre>\u003Ccode>\u002F\u002F Same host and port for every type: the username selects it\nuser, pass := os.Getenv(\"PROXYHAT_USER\"), os.Getenv(\"PROXYHAT_PASS\")\nresidential := fmt.Sprintf(\"http:\u002F\u002F%s:%s@gate.proxyhat.com:8080\", user, pass)\nmobile := fmt.Sprintf(\"http:\u002F\u002F%s-type-mobile:%s@gate.proxyhat.com:8080\", user, pass)\n\u002F\u002F datacenter: coming soon at ProxyHat\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Ch2>Configuring http.Transport for Proxies\u003C\u002Fh2>\n\u003Cp>For full control, configure the \u003Ccode>http.Transport\u003C\u002Fcode> directly. This lets you tune connection pooling, TLS settings, and timeouts:\u003C\u002Fp>\n\u003Cpre>\u003Ccode>package main\nimport (\n    \"crypto\u002Ftls\"\n    \"net\u002Fhttp\"\n    \"net\u002Furl\"\n    \"time\"\n)\nfunc newProxyClient(proxyAddr string) (*http.Client, error) {\n    proxyURL, err := url.Parse(proxyAddr)\n    if err != nil {\n        return nil, err\n    }\n    transport := &http.Transport{\n        Proxy:               http.ProxyURL(proxyURL),\n        MaxIdleConns:        100,\n        MaxIdleConnsPerHost: 10,\n        IdleConnTimeout:     90 * time.Second,\n        TLSClientConfig:     &tls.Config{MinVersion: tls.VersionTLS12},\n    }\n    client := &http.Client{\n        Transport: transport,\n        Timeout:   30 * time.Second,\n    }\n    return client, nil\n}\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Ch2>Looking Up Locations and Usage with the ProxyHat Go SDK\u003C\u002Fh2>\n\u003Cp>The \u003Ca href=\"https:\u002F\u002Fgithub.com\u002FProxyHatCom\u002Fgo-sdk\" rel=\"noopener noreferrer\">ProxyHat Go SDK\u003C\u002Fa> talks to the account API with your API key. Two things it is handy for in a scraper: finding the exact region and city codes for geo-targeting, and checking how much traffic each sub-user has used.\u003C\u002Fp>\n\u003Cpre>\u003Ccode>package main\n\nimport (\n    \"context\"\n    \"fmt\"\n    \"log\"\n    \"os\"\n\n    proxyhat \"github.com\u002FProxyHatCom\u002Fgo-sdk\"\n)\n\nfunc main() {\n    client := proxyhat.NewClient(os.Getenv(\"PROXYHAT_API_KEY\"))\n    ctx := context.Background()\n\n    \u002F\u002F City codes for geo-targeting. A city always needs its region.\n    country, region := \"us\", \"new_york\"\n    cities, err := client.Locations.Cities(ctx, &amp;proxyhat.CityParams{\n        RegionParams: proxyhat.RegionParams{CountryCode: &amp;country},\n        RegionCode:   &amp;region,\n    })\n    if err != nil {\n        log.Fatal(err)\n    }\n    for _, c := range cities {\n        fmt.Printf(\"%-20s -country-%s-region-%s-city-%s\\n\", c.Name, country, region, c.Code)\n    }\n\n    \u002F\u002F Traffic used by each sub-user\n    users, err := client.SubUsers.List(ctx)\n    if err != nil {\n        log.Fatal(err)\n    }\n    for _, u := range users {\n        fmt.Println(u.ProxyUsername, u.LifecycleStatus, \"used:\", u.UsedTraffic)\n    }\n}\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>The SDK returns typed structs and API errors. Check the \u003Ca href=\"https:\u002F\u002Fdocs.proxyhat.com\u002F\" rel=\"noopener noreferrer\">API documentation\u003C\u002Fa> for the full method reference.\u003C\u002Fp>\n\u003Ch2>Rotating vs Sticky Sessions\u003C\u002Fh2>\n\u003Cp>ProxyHat supports two session modes:\u003C\u002Fp>\n\u003Cul>\n\u003Cli>\u003Cstrong>Rotating (default)\u003C\u002Fstrong> &mdash; every new connection gets a new IP. Ideal for large-scale \u003Ca href=\"\u002Fuse-cases\u002Fweb-scraping\">web scraping\u003C\u002Fa>.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Sticky\u003C\u002Fstrong> &mdash; the same IP is held for the duration you set in the username (from one minute up to 24 hours). Useful for multi-step flows like login sequences or paginated crawls.\u003C\u002Fli>\n\u003C\u002Ful>\n\u003Ch3>Rotating sessions\u003C\u002Fh3>\n\u003Cp>Go reuses connections by default, and a reused tunnel keeps the same exit IP. To get a new IP on every request, switch keep-alive off:\u003C\u002Fp>\n\u003Cpre>\u003Ccode>proxyURL := &amp;url.URL{\n    Scheme: \"http\",\n    User:   url.UserPassword(os.Getenv(\"PROXYHAT_USER\"), os.Getenv(\"PROXYHAT_PASS\")),\n    Host:   \"gate.proxyhat.com:8080\",\n}\n\u002F\u002F No session flags = rotating. Turn keep-alive off so each request opens\n\u002F\u002F a new tunnel through the gateway and gets a new exit IP.\nclient := &amp;http.Client{\n    Transport: &amp;http.Transport{\n        Proxy:             http.ProxyURL(proxyURL),\n        DisableKeepAlives: true,\n    },\n    Timeout: 30 * time.Second,\n}\nfor i := 0; i &lt; 5; i++ {\n    resp, err := client.Get(\"https:\u002F\u002Fapi.ipify.org\")\n    if err != nil {\n        log.Println(err)\n        continue\n    }\n    ip, _ := io.ReadAll(resp.Body)\n    resp.Body.Close()\n    fmt.Printf(\"Request %d: %s\\n\", i+1, ip)\n}\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Ch3>Sticky sessions\u003C\u002Fh3>\n\u003Cp>Add a session ID (8&ndash;32 hex characters) and a lifetime to the username. All requests with the same ID exit from the same IP until the lifetime runs out:\u003C\u002Fp>\n\u003Cpre>\u003Ccode>\u002F\u002F Sticky: -sid-&lt;hex id&gt;-ttl-&lt;duration&gt; keeps one exit IP for the session\nsid := make([]byte, 8)\nif _, err := rand.Read(sid); err != nil { \u002F\u002F crypto\u002Frand\n    log.Fatal(err)\n}\nusername := fmt.Sprintf(\"%s-country-us-sid-%x-ttl-10m\", os.Getenv(\"PROXYHAT_USER\"), sid)\nproxyURL := &amp;url.URL{\n    Scheme: \"http\",\n    User:   url.UserPassword(username, os.Getenv(\"PROXYHAT_PASS\")),\n    Host:   \"gate.proxyhat.com:8080\",\n}\nclient := &amp;http.Client{\n    Transport: &amp;http.Transport{Proxy: http.ProxyURL(proxyURL)},\n    Timeout:   30 * time.Second,\n}\n\u002F\u002F Every request through this client exits from the same IP for 10 minutes\nresp1, err := client.Get(\"https:\u002F\u002Fexample.com\u002Flogin\")\n\u002F\u002F ...\nresp2, err := client.Get(\"https:\u002F\u002Fexample.com\u002Faccount\")\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Ch3>One session per worker\u003C\u002Fh3>\n\u003Cp>If you run sticky sessions in parallel, give each goroutine its own session ID instead of sharing one:\u003C\u002Fp>\n\u003Cpre>\u003Ccode>\u002F\u002F One session ID per worker: a single sticky session is not meant\n\u002F\u002F to carry dozens of parallel connections\nfunc newSessionID() string {\n    b := make([]byte, 8)\n    rand.Read(b)\n    return hex.EncodeToString(b)\n}\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Ch2>Geo-Targeted Requests\u003C\u002Fh2>\n\u003Cp>Need IPs from a specific country? ProxyHat supports \u003Ca href=\"\u002Flocations\">190+ locations\u003C\u002Fa>. Add the location to the username; region and city codes come from the locations API (see the SDK example above):\u003C\u002Fp>\n\u003Cpre>\u003Ccode>user := os.Getenv(\"PROXYHAT_USER\")\n\n\u002F\u002F Country only (ISO 3166-1 alpha-2, lower case)\nus := user + \"-country-us\"\n\n\u002F\u002F Region + city: the city code always follows its region code\nnyc := user + \"-country-us-region-new_york-city-new_york_city\"\n\n\u002F\u002F Mobile exit in Germany\ndeMobile := user + \"-country-de-type-mobile\"\n\n\u002F\u002F Build the proxy URL from any of them\nproxyURL := &amp;url.URL{\n    Scheme: \"http\",\n    User:   url.UserPassword(nyc, os.Getenv(\"PROXYHAT_PASS\")),\n    Host:   \"gate.proxyhat.com:8080\",\n}\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>Geo-targeting is essential for localized \u003Ca href=\"\u002Fuse-cases\u002Fserp-tracking\">SERP tracking\u003C\u002Fa>, regional pricing checks, and content availability testing.\u003C\u002Fp>\n\u003Ch2>Error Handling and Retries\u003C\u002Fh2>\n\u003Cp>Network requests through proxies can fail for transient reasons: connection resets, timeouts, or temporary blocks. Robust error handling is critical for production scrapers.\u003C\u002Fp>\n\u003Ch3>Which errors to retry\u003C\u002Fh3>\n\u003Cpre>\u003Ccode>\u002F\u002F retryable reports whether a failed request is worth repeating.\n\u002F\u002F \"Proxy Authentication Required\" (407) means wrong credentials or an\n\u002F\u002F unknown username flag: retrying the same request will not fix it.\nfunc retryable(resp *http.Response, err error) bool {\n    if err != nil {\n        return !strings.Contains(err.Error(), \"Proxy Authentication Required\")\n    }\n    return resp.StatusCode == http.StatusTooManyRequests || resp.StatusCode &gt;= 500\n}\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Ch3>Manual retry with exponential backoff\u003C\u002Fh3>\n\u003Cpre>\u003Ccode>package main\nimport (\n    \"fmt\"\n    \"math\"\n    \"net\u002Fhttp\"\n    \"time\"\n)\nfunc fetchWithRetry(client *http.Client, url string, maxRetries int) (*http.Response, error) {\n    var lastErr error\n    for attempt := 0; attempt &lt;= maxRetries; attempt++ {\n        resp, err := client.Get(url)\n        if err == nil &amp;&amp; resp.StatusCode &lt; 500 {\n            return resp, nil\n        }\n        if err != nil {\n            lastErr = err\n        } else {\n            lastErr = fmt.Errorf(\"HTTP %d\", resp.StatusCode)\n            resp.Body.Close()\n        }\n        backoff := time.Duration(math.Pow(2, float64(attempt))) * time.Second\n        time.Sleep(backoff)\n    }\n    return nil, fmt.Errorf(\"all %d retries failed: %w\", maxRetries, lastErr)\n}\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Ch2>Concurrent Scraping with Goroutines\u003C\u002Fh2>\n\u003Cp>Go's concurrency model is its superpower. With goroutines and channels, you can scrape hundreds of URLs concurrently while keeping memory usage minimal.\u003C\u002Fp>\n\u003Cpre>\u003Ccode>package main\n\nimport (\n    \"fmt\"\n    \"io\"\n    \"net\u002Fhttp\"\n    \"net\u002Furl\"\n    \"os\"\n    \"sync\"\n    \"time\"\n)\n\ntype Result struct {\n    URL        string\n    StatusCode int\n    Body       string\n    Err        error\n}\n\nfunc scrape(client *http.Client, urls []string, concurrency int) []Result {\n    results := make([]Result, len(urls))\n    sem := make(chan struct{}, concurrency) \u002F\u002F semaphore\n    var wg sync.WaitGroup\n    for i, u := range urls {\n        wg.Add(1)\n        go func(idx int, target string) {\n            defer wg.Done()\n            sem &lt;- struct{}{}        \u002F\u002F acquire\n            defer func() { &lt;-sem }() \u002F\u002F release\n            resp, err := client.Get(target)\n            if err != nil {\n                results[idx] = Result{URL: target, Err: err}\n                return\n            }\n            defer resp.Body.Close()\n            body, err := io.ReadAll(resp.Body)\n            results[idx] = Result{\n                URL:        target,\n                StatusCode: resp.StatusCode,\n                Body:       string(body),\n                Err:        err,\n            }\n        }(i, u)\n    }\n    wg.Wait()\n    return results\n}\n\nfunc main() {\n    proxyURL := &amp;url.URL{\n        Scheme: \"http\",\n        User:   url.UserPassword(os.Getenv(\"PROXYHAT_USER\"), os.Getenv(\"PROXYHAT_PASS\")),\n        Host:   \"gate.proxyhat.com:8080\",\n    }\n    client := &amp;http.Client{\n        Transport: &amp;http.Transport{\n            Proxy:               http.ProxyURL(proxyURL),\n            MaxIdleConnsPerHost: 20,\n        },\n        Timeout: 30 * time.Second,\n    }\n    urls := []string{\n        \"https:\u002F\u002Fexample.com\u002Fpage\u002F1\",\n        \"https:\u002F\u002Fexample.com\u002Fpage\u002F2\",\n        \"https:\u002F\u002Fexample.com\u002Fpage\u002F3\",\n        \u002F\u002F ... hundreds more\n    }\n    results := scrape(client, urls, 20)\n    for _, r := range results {\n        if r.Err != nil {\n            fmt.Printf(\"FAIL %s: %v\\n\", r.URL, r.Err)\n        } else {\n            fmt.Printf(\"OK   %s: %d bytes\\n\", r.URL, len(r.Body))\n        }\n    }\n}\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Ch2>Rate Limiting with a Semaphore\u003C\u002Fh2>\n\u003Cp>The scraper above already uses a semaphore channel to cap concurrency. For finer-grained rate limiting (e.g., N requests per second), use \u003Ccode>golang.org\u002Fx\u002Ftime\u002Frate\u003C\u002Fcode>:\u003C\u002Fp>\n\u003Cpre>\u003Ccode>package main\n\nimport (\n    \"context\"\n    \"fmt\"\n    \"log\"\n    \"net\u002Fhttp\"\n    \"net\u002Furl\"\n    \"os\"\n    \"time\"\n\n    \"golang.org\u002Fx\u002Ftime\u002Frate\"\n)\n\nfunc main() {\n    proxyURL := &amp;url.URL{\n        Scheme: \"http\",\n        User:   url.UserPassword(os.Getenv(\"PROXYHAT_USER\"), os.Getenv(\"PROXYHAT_PASS\")),\n        Host:   \"gate.proxyhat.com:8080\",\n    }\n    client := &amp;http.Client{\n        Transport: &amp;http.Transport{Proxy: http.ProxyURL(proxyURL)},\n        Timeout:   30 * time.Second,\n    }\n    \u002F\u002F Allow 10 requests per second, burst of 20\n    limiter := rate.NewLimiter(10, 20)\n    urls := []string{\"https:\u002F\u002Fexample.com\u002F1\", \"https:\u002F\u002Fexample.com\u002F2\"}\n    for _, u := range urls {\n        if err := limiter.Wait(context.Background()); err != nil {\n            log.Fatal(err)\n        }\n        resp, err := client.Get(u)\n        if err != nil {\n            fmt.Printf(\"Error: %v\\n\", err)\n            continue\n        }\n        resp.Body.Close()\n        fmt.Printf(\"%s - %d\\n\", u, resp.StatusCode)\n    }\n}\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Ch2>Production Tips\u003C\u002Fh2>\n\u003Ch3>Connection pooling\u003C\u002Fh3>\n\u003Cp>Go's \u003Ccode>http.Transport\u003C\u002Fcode> maintains a pool of idle connections by default. For proxy workloads, tune these settings:\u003C\u002Fp>\n\u003Cpre>\u003Ccode>transport := &http.Transport{\n    Proxy:                 http.ProxyURL(proxyURL),\n    MaxIdleConns:          200,\n    MaxIdleConnsPerHost:   50,\n    MaxConnsPerHost:       100,\n    IdleConnTimeout:       90 * time.Second,\n    ResponseHeaderTimeout: 15 * time.Second,\n}\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Ch3>Timeouts\u003C\u002Fh3>\n\u003Cp>Always set timeouts. A scraper without timeouts will eventually hang on a stalled connection:\u003C\u002Fp>\n\u003Cpre>\u003Ccode>client := &http.Client{\n    Transport: transport,\n    Timeout:   30 * time.Second, \u002F\u002F total request timeout\n}\n\u002F\u002F Or use context for per-request control\nctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)\ndefer cancel()\nreq, _ := http.NewRequestWithContext(ctx, \"GET\", targetURL, nil)\nresp, err := client.Do(req)\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Ch3>Graceful shutdown\u003C\u002Fh3>\n\u003Cp>In long-running scrapers, listen for OS signals to shut down cleanly:\u003C\u002Fp>\n\u003Cpre>\u003Ccode>package main\nimport (\n    \"context\"\n    \"os\"\n    \"os\u002Fsignal\"\n    \"syscall\"\n)\nfunc main() {\n    ctx, stop := signal.NotifyContext(\n        context.Background(),\n        os.Interrupt, syscall.SIGTERM,\n    )\n    defer stop()\n    \u002F\u002F Pass ctx to your scraping functions\n    \u002F\u002F When Ctrl+C is pressed, ctx is cancelled\n    \u002F\u002F and in-flight requests wind down gracefully\n    runScraper(ctx)\n}\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Ch3>Logging and observability\u003C\u002Fh3>\n\u003Cp>Wrap your HTTP transport to log request timing and status codes. This helps identify slow targets and proxy errors in production:\u003C\u002Fp>\n\u003Cpre>\u003Ccode>type loggingTransport struct {\n    inner http.RoundTripper\n}\nfunc (t *loggingTransport) RoundTrip(req *http.Request) (*http.Response, error) {\n    start := time.Now()\n    resp, err := t.inner.RoundTrip(req)\n    elapsed := time.Since(start)\n    if err != nil {\n        log.Printf(\"ERR  %s %s (%v) err=%v\", req.Method, req.URL, elapsed, err)\n    } else {\n        log.Printf(\"OK   %s %s (%v) status=%d\", req.Method, req.URL, elapsed, resp.StatusCode)\n    }\n    return resp, err\n}\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cblockquote>\n\u003Ch3>Key Takeaways\u003C\u002Fh3>\n\u003Cul>\n\u003Cli>Go's goroutines + proxies = massive concurrency. You can run thousands of proxy-routed requests with minimal memory overhead.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>The standard library is all you need\u003C\u002Fstrong> to send traffic through ProxyHat: set \u003Ccode>Proxy\u003C\u002Fcode> on \u003Ccode>http.Transport\u003C\u002Fcode> and put targeting flags in the username. The \u003Ca href=\"https:\u002F\u002Fgithub.com\u002FProxyHatCom\u002Fgo-sdk\" rel=\"noopener noreferrer\">ProxyHat Go SDK\u003C\u002Fa> covers the account API (locations, sub-users, usage).\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Use rotating IPs\u003C\u002Fstrong> for scraping at scale (with keep-alive off for a new IP per request) and \u003Cstrong>sticky sessions\u003C\u002Fstrong> for multi-step workflows like login flows.\u003C\u002Fli>\n\u003Cli>Always set timeouts on both the \u003Ccode>http.Client\u003C\u002Fcode> and via \u003Ccode>context.WithTimeout\u003C\u002Fcode> for per-request control.\u003C\u002Fli>\n\u003Cli>Rate-limit responsibly with \u003Ccode>golang.org\u002Fx\u002Ftime\u002Frate\u003C\u002Fcode> and cap concurrency with semaphore channels.\u003C\u002Fli>\n\u003Cli>Geo-target your requests with country, region and city codes in the username to access \u003Ca href=\"\u002Flocations\">190+ locations\u003C\u002Fa> worldwide.\u003C\u002Fli>\n\u003Cli>Check our guide on the \u003Ca href=\"\u002Fblog\u002Fbest-proxies-for-web-scraping-2026\">best proxies for web scraping\u003C\u002Fa> to choose the right plan for your workload.\u003C\u002Fli>\n\u003C\u002Ful>\n\u003C\u002Fblockquote>","Using Proxies in Go (HTTP Client + SDK)","Configure proxies in Go with net\u002Fhttp and the ProxyHat SDK. Code examples for rotation, sticky sessions, geo-targeting, and concurrent scraping with goroutines.","\u002Fblog\u002Fusing-proxies-in-go",null,"Using Proxies in Go (HTTP Client + SDK) | ProxyHat","Configure proxies in Go with net\u002Fhttp and the ProxyHat SDK. Code examples for rotation, sticky sessions, geo-targeting, and concurrent scraping.","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog\u002Fusing-proxies-in-go-og.webp",[19,22,25,28,31],{"question":20,"answer":21},"How do I configure a proxy in Go's net\u002Fhttp client?","Set the Proxy field on http.Transport to http.ProxyURL(parsedURL) where parsedURL is your proxy address parsed with url.Parse(). Then pass the transport to http.Client. The standard library handles CONNECT tunneling for HTTPS targets automatically.",{"question":23,"answer":24},"What does the ProxyHat Go SDK do?","It is a typed client for the ProxyHat account API: managing sub-users, looking up country, region and city codes, and reading usage analytics. Proxy traffic itself goes through Go's net\u002Fhttp with the gateway URL, which handles HTTPS targets through CONNECT tunneling, so traffic stays encrypted end-to-end between your client and the target server.",{"question":26,"answer":27},"How many concurrent requests can I make through Go proxies?","Go's goroutines are extremely lightweight (roughly 4 KB of stack each), so you can run tens of thousands concurrently. In practice the limit is the target server's capacity and your own rate limits. For sticky sessions, give each worker its own session ID rather than sharing one. Use a semaphore channel to cap concurrency at a safe level.",{"question":29,"answer":30},"What is the difference between rotating and sticky proxy sessions?","Rotating sessions assign a new IP address to every request, which is ideal for broad scraping. Sticky sessions keep the same IP for the duration you set (from one minute up to 24 hours), making them suitable for multi-step flows where the target expects a consistent visitor, such as login sequences or checkout pages.",{"question":32,"answer":33},"How do I handle proxy errors and retries in Go?","Retry timeouts, connection resets, 429 and 5xx responses with exponential backoff: wrap the request in a loop that doubles the delay after each failed attempt. Do not retry a 407 Proxy Authentication Required: it means wrong credentials or an unknown username flag. For sticky sessions, switch to a new session ID if the same IP keeps failing.",[35,36,37,38,39],"Go's concurrency and standard library make it ideal for building high-performance proxy-powered web scrapers and API clients.","You can route Go traffic through ProxyHat with the standard net\u002Fhttp library alone; the ProxyHat Go SDK covers the account API, such as location codes and sub-user usage.","ProxyHat offers residential and mobile proxies (datacenter is coming soon), selected with a username flag on the same port.","Use rotating sessions for large-scale scraping to get a new IP per request, and sticky sessions for multi-step workflows like logins.","For production scrapers, tune connection pooling, set strict timeouts, and implement graceful shutdowns to ensure stability.",false,"2026-01-08T19:01:42+00:00","2026-07-19T03:13:07+00:00","2026-11-17T10:32:41+00:00","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog\u002Fusing-proxies-in-go-master.webp","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog\u002Fusing-proxies-in-go-card.webp",13,{"name":48,"slug":49,"bio":50,"avatar_url":14,"website_url":14,"social_links":14},"ProxyHat Team","proxyhat-team","The ProxyHat editorial team covers proxies, web scraping, and data extraction.",[52],{"id":53,"slug":54,"name":55,"description":14,"meta_title":56,"meta_description":57,"parent_id":14},4,"developer-guides","Developer Guides","Developer Guides | ProxyHat Blog","Code tutorials and SDK guides for integrating proxies into your applications.",[59,63,67],{"id":60,"slug":61,"name":62},1,"web-scraping","Web Scraping",{"id":64,"slug":65,"name":66},11,"golang","Go",{"id":68,"slug":69,"name":70},12,"sdk","SDK",{"tr":72,"fr":73,"zh":74,"it":75,"de":76,"en":13,"ru":77,"ja":78,"pt":79,"es":80,"ko":81,"pl":82,"x-default":13},"\u002Ftr\u002Fblog\u002Fgo-ile-proxy-kullanimi","\u002Ffr\u002Fblog\u002Futiliser-des-proxies-en-go","\u002Fcn\u002Fblog\u002Fgo-yuyan-shiyong-daili","\u002Fit\u002Fblog\u002Futilizzo-dei-proxy-in-go-guida-http-client-sdk","\u002Fde\u002Fblog\u002Fproxies-in-go-verwenden","\u002Fru\u002Fblog\u002Fispolzovanie-proksi-v-go","\u002Fja\u002Fblog\u002Fgo-de-prokishi-wo-tsukau","\u002Fpt\u002Fblog\u002Fusando-proxies-em-go","\u002Fes\u002Fblog\u002Fusar-proxies-en-go","\u002Fko\u002Fblog\u002Fgo-proxy-sayongbeop","\u002Fpl\u002Fblog\u002Fkorzystanie-z-proxies-in-go-http-client-sdk-guide",{"tr":72,"fr":73,"zh":74,"it":75,"de":76,"en":13,"ru":77,"ja":78,"pt":79,"es":80,"ko":81,"pl":82},79,[86,103,120,140],{"id":87,"slug":88,"title":89,"excerpt":90,"featured_image_url":91,"featured_image_alt":14,"card_image_url":92,"og_image_url":93,"published_at":94,"updated_at":42,"content_updated_at":95,"reading_time_minutes":68,"is_featured":40,"indexable":40,"views":96,"author":97,"categories":98,"tags":100},50,"reliable-scraping-architecture","Designing a Reliable Scraping Architecture","Design an end-to-end scraping system: scheduler, URL queue, crawler pool, proxy layer, parser, storage, and monitoring. Production-ready Python code with architecture diagrams.","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog\u002Freliable-scraping-architecture-master.webp","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog\u002Freliable-scraping-architecture-card.webp","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog\u002Freliable-scraping-architecture-og.webp","2026-02-24T06:55:16+00:00","2026-10-03T08:21:20+00:00",68,{"name":48,"slug":49,"bio":50,"avatar_url":14,"website_url":14,"social_links":14},[99],{"id":53,"slug":54,"name":55,"description":14,"meta_title":56,"meta_description":57,"parent_id":14},[101,102],{"id":68,"slug":69,"name":70},{"id":60,"slug":61,"name":62},{"id":104,"slug":105,"title":106,"excerpt":107,"featured_image_url":108,"featured_image_alt":14,"card_image_url":109,"og_image_url":110,"published_at":111,"updated_at":42,"content_updated_at":112,"reading_time_minutes":64,"is_featured":40,"indexable":40,"views":113,"author":114,"categories":115,"tags":117},41,"monitoring-proxy-performance","Monitoring Proxy Performance: Latency, Success Rate, and Alerts","Learn how to instrument, monitor, and alert on proxy performance — track latency percentiles, success rates, error patterns, and bandwidth. Code examples in Python, Node.js, and Go.","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog\u002Fmonitoring-proxy-performance-master.webp","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog\u002Fmonitoring-proxy-performance-card.webp","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog\u002Fmonitoring-proxy-performance-og.webp","2026-02-15T00:39:23+00:00","2026-10-03T08:21:37+00:00",75,{"name":48,"slug":49,"bio":50,"avatar_url":14,"website_url":14,"social_links":14},[116],{"id":53,"slug":54,"name":55,"description":14,"meta_title":56,"meta_description":57,"parent_id":14},[118,119],{"id":68,"slug":69,"name":70},{"id":60,"slug":61,"name":62},{"id":121,"slug":122,"title":123,"excerpt":124,"featured_image_url":125,"featured_image_alt":14,"card_image_url":126,"og_image_url":127,"published_at":128,"updated_at":42,"content_updated_at":129,"reading_time_minutes":130,"is_featured":40,"indexable":40,"views":131,"author":132,"categories":133,"tags":137},36,"scale-scraping-infrastructure","How to Scale Scraping Infrastructure","Architecture patterns for scaling web scraping: queue-based systems, pipeline design, horizontal scaling with containers, and proxy management at scale. Code in Python, Node.js, and Go.","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog\u002Fscale-scraping-infrastructure-master.webp","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog\u002Fscale-scraping-infrastructure-card.webp","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog\u002Fscale-scraping-infrastructure-og.webp","2026-02-09T14:42:34+00:00","2026-02-25T23:52:12+00:00",10,49,{"name":48,"slug":49,"bio":50,"avatar_url":14,"website_url":14,"social_links":14},[134],{"id":60,"slug":61,"name":62,"description":14,"meta_title":135,"meta_description":136,"parent_id":14},"Web Scraping Guides & Tips | ProxyHat Blog","Learn web scraping techniques, proxy strategies, and data extraction best practices.",[138,139],{"id":60,"slug":61,"name":62},{"id":68,"slug":69,"name":70},{"id":141,"slug":142,"title":143,"excerpt":144,"featured_image_url":145,"featured_image_alt":14,"card_image_url":146,"og_image_url":147,"published_at":148,"updated_at":42,"content_updated_at":149,"reading_time_minutes":68,"is_featured":40,"indexable":40,"views":150,"author":151,"categories":152,"tags":154},35,"scaling-proxy-requests-concurrency","Scaling Proxy Requests with Concurrency Control","Master concurrency patterns for proxy-based scraping: asyncio semaphores, Promise pools, Go worker pools, rate limiters, and backpressure. Production code in Python, Node.js, and Go.","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog\u002Fscaling-proxy-requests-concurrency-master.webp","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog\u002Fscaling-proxy-requests-concurrency-card.webp","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog\u002Fscaling-proxy-requests-concurrency-og.webp","2026-02-08T11:16:13+00:00","2026-10-03T08:21:21+00:00",358,{"name":48,"slug":49,"bio":50,"avatar_url":14,"website_url":14,"social_links":14},[153],{"id":53,"slug":54,"name":55,"description":14,"meta_title":56,"meta_description":57,"parent_id":14},[155,156],{"id":68,"slug":69,"name":70},{"id":60,"slug":61,"name":62},[]]