I'm using Charles to debug HTTP requests, but it seems that Go's network stack ignores the system proxy settings (on OSX) and the requests are not logged.
How do I tell Go that the requests should use the proxy?
I'm using Charles to debug HTTP requests, but it seems that Go's network stack ignores the system proxy settings (on OSX) and the requests are not logged.
How do I tell Go that the requests should use the proxy?
You can get proxy info using ProxyFromEnvironment function. Then you create http client using transport (represented by RoundTripper interface) that has info about your proxy settings:
var PTransport http.RoundTripper = &http.Transport{Proxy: http.ProxyFromEnvironment}
client := http.Client{Transport: PTransport}
Then you just do http request using the info transport gets from passed function to Proxy
struct field. Proxy info will be taken from $HTTP_PROXY
environment variable.