A Golang library for retrieving system proxy settings
- Windows (HTTP)
- Darwin (HTTP/HTTPS)
package main
import (
"fmt""github.com/oomol-lab/sysproxy"
)
funcmain() {
httpInfo, _:=sysproxy.GetHTTP()
ifhttpInfo!=nil {
fmt.Printf("http proxy host: %s, port: %d \n", httpInfo.Host, httpInfo.Port)
}
// Since Windows does not support setting an HTTPS proxy// GetHTTPS will always return nil with no error on the Windows platformhttpsInfo, _:=sysproxy.GetHTTPS()
ifhttpsInfo!=nil {
fmt.Printf("https proxy host: %s, port: %d \n", httpsInfo.Host, httpsInfo.Port)
}
// You can also using sysproxy.GetAll() get all proxy settings// httpInfo, httpsInfo, _ := sysproxy.GetAll()
}