本文整理汇总了Golang中github.com/juju/utils/proxy.Settings.Https方法的典型用法代码示例。如果您正苦于以下问题:Golang Settings.Https方法的具体用法?Golang Settings.Https怎么用?Golang Settings.Https使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/utils/proxy.Settings
的用法示例。
在下文中一共展示了Settings.Https方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GetProxySettings
// GetProxySettings is defined on the PackageManager interface.
func (apt *apt) GetProxySettings() (proxy.Settings, error) {
var res proxy.Settings
args := strings.Fields(apt.cmder.GetProxyCmd())
if len(args) <= 1 {
return proxy.Settings{}, fmt.Errorf("expected at least 2 arguments, got %d %v", len(args), args)
}
cmd := exec.Command(args[0], args[1:]...)
out, err := CommandOutput(cmd)
if err != nil {
logger.Errorf("command failed: %v\nargs: %#v\n%s",
err, args, string(out))
return res, fmt.Errorf("command failed: %v", err)
}
output := string(bytes.Join(proxyRE.FindAll(out, -1), []byte("\n")))
for _, match := range proxyRE.FindAllStringSubmatch(output, -1) {
switch match[1] {
case "http":
res.Http = match[2]
case "https":
res.Https = match[2]
case "ftp":
res.Ftp = match[2]
}
}
return res, nil
}
示例2: GetProxySettings
// GetProxySettings is defined on the PackageManager interface.
func (yum *yum) GetProxySettings() (proxy.Settings, error) {
var res proxy.Settings
args := strings.Fields(yum.cmder.GetProxyCmd())
if len(args) <= 1 {
return proxy.Settings{}, fmt.Errorf("expected at least 2 arguments, got %d %v", len(args), args)
}
cmd := exec.Command(args[0], args[1:]...)
out, err := CommandOutput(cmd)
if err != nil {
logger.Errorf("command failed: %v\nargs: %#v\n%s",
err, args, string(out))
return res, fmt.Errorf("command failed: %v", err)
}
for _, match := range strings.Split(string(out), "\n") {
fields := strings.Split(match, "=")
if len(fields) != 2 {
continue
}
if strings.HasPrefix(fields[0], "https") {
res.Https = strings.TrimSpace(fields[1])
} else if strings.HasPrefix(fields[0], "http") {
res.Http = strings.TrimSpace(fields[1])
} else if strings.HasPrefix(fields[0], "ftp") {
res.Ftp = strings.TrimSpace(fields[1])
}
}
return res, nil
}