For golang how to use forward http proxy, here’s a real-world example with auth:
```go
proxyURL := "http://user:pass@proxy:port"
transport := &http.Transport{
Proxy: http.ProxyURL(proxyURL),
IdleConnTimeout: 30 * time.Second,
}
client := &http.Client{Transport: transport}
```
Biggest gotcha? *Always* close response bodies (`defer resp.Body.Close()`), or you’ll leak connections.
```go
proxyURL := "http://user:pass@proxy:port"
transport := &http.Transport{
Proxy: http.ProxyURL(proxyURL),
IdleConnTimeout: 30 * time.Second,
}
client := &http.Client{Transport: transport}
```
Biggest gotcha? *Always* close response bodies (`defer resp.Body.Close()`), or you’ll leak connections.
