Discovering system proxy

I am new to Go and am thinking of re-writing some code I wrote in Python for a cross-platform app (Win/MacOS/Linus) in Go that I can also compile for Mobile devices using the same code base. Most of what it does I think I can replicate fairly easily but one critical feature is to automatically discover the proxy settings of the host system. In python I used urllib2.getproxies() and, if none are set, looked for a WPAD file and parsed it.

What I can’t find is any way in Go to see if the host system has any proxies set. This is not the same as setting/reading the http_proxy/https_proxy environment variables - it is the ability to read the os specific system preference settings.

Is this possible?

Maybe take a look at this:

Many thanks - that looks perfect! Do you know if it works for Android and iOS as well?

Now I’ve had a chance to look at this more closely there is a problem. It will get the system proxy on all O/Ss but if the proxy is set by wpad then this only woks for Windows. I can grab the wpad.dat file itself but I can’t find a parser for it - specifically I need to work out which of, possibly, multiple proxies defined in wpad file are used for a particular URL. In python there is a pacparser script which does this. Does anyone know if there a similar thing someone has written in Go?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.