本文整理匯總了Golang中github.com/juju/utils/proxy.Settings.SetEnvironmentValues方法的典型用法代碼示例。如果您正苦於以下問題:Golang Settings.SetEnvironmentValues方法的具體用法?Golang Settings.SetEnvironmentValues怎麽用?Golang Settings.SetEnvironmentValues使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/juju/utils/proxy.Settings
的用法示例。
在下文中一共展示了Settings.SetEnvironmentValues方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestSetEnvironmentValues
func (s *proxySuite) TestSetEnvironmentValues(c *gc.C) {
s.PatchEnvironment("http_proxy", "initial")
s.PatchEnvironment("HTTP_PROXY", "initial")
s.PatchEnvironment("https_proxy", "initial")
s.PatchEnvironment("HTTPS_PROXY", "initial")
s.PatchEnvironment("ftp_proxy", "initial")
s.PatchEnvironment("FTP_PROXY", "initial")
s.PatchEnvironment("no_proxy", "initial")
s.PatchEnvironment("NO_PROXY", "initial")
proxySettings := proxy.Settings{
Http: "http proxy",
Https: "https proxy",
// Ftp left blank to show clearing env.
NoProxy: "10.0.3.1,localhost",
}
proxySettings.SetEnvironmentValues()
obtained := proxy.DetectProxies()
c.Assert(obtained, gc.DeepEquals, proxySettings)
c.Assert(os.Getenv("http_proxy"), gc.Equals, "http proxy")
c.Assert(os.Getenv("HTTP_PROXY"), gc.Equals, "http proxy")
c.Assert(os.Getenv("https_proxy"), gc.Equals, "https proxy")
c.Assert(os.Getenv("HTTPS_PROXY"), gc.Equals, "https proxy")
c.Assert(os.Getenv("ftp_proxy"), gc.Equals, "")
c.Assert(os.Getenv("FTP_PROXY"), gc.Equals, "")
c.Assert(os.Getenv("no_proxy"), gc.Equals, "10.0.3.1,localhost")
c.Assert(os.Getenv("NO_PROXY"), gc.Equals, "10.0.3.1,localhost")
}
示例2: handleProxyValues
func (w *proxyWorker) handleProxyValues(proxySettings proxyutils.Settings) {
proxySettings.SetEnvironmentValues()
if proxySettings != w.proxy || w.first {
logger.Debugf("new proxy settings %#v", proxySettings)
w.proxy = proxySettings
if err := w.writeEnvironment(); err != nil {
// It isn't really fatal, but we should record it.
logger.Errorf("error writing proxy environment file: %v", err)
}
}
}