本文整理汇总了Golang中flag.Set函数的典型用法代码示例。如果您正苦于以下问题:Golang Set函数的具体用法?Golang Set怎么用?Golang Set使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了Set函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: main

func main() {

    role := flag.String("role", "master", "Escort role")
    flag.Set("alsologtostderr", "true")
    flag.Set("v", "5")
    flag.Parse()

    if role == nil || len(*role) == 0 {
        Usage()
        return
    }

    glog.Infoln(*role)

    switch *role {
    case "master":
        // 主服务
        server.Work()
    case "slave":
        // 备份服务
        client.Work()
    default:
        Usage()
    }
}

开发者ID:sdgdsffdsfff,项目名称:escort,代码行数:25,代码来源:escort.go

示例2: ExampleFlightGetBadID

// ExampleFlightGetBadID tests giving a non integer as ID value, with null output
func ExampleFlightGetBadID() {
    _ = flag.Set("id", "i")
    _ = flag.Set("startID", "")
    _ = flag.Set("max", "")
    runFlightGet(CmdFlightGet, []string{})
    // Output:
}

开发者ID:rochaporto,项目名称:ezgliding,代码行数:8,代码来源:flight_test.go

示例3: Init

func Init() error {
    Program = filepath.Base(os.Args[0])
    if !isPidInitialize() {
        if "windows" == runtime.GOOS {
            flag.Set("pid_file", Program+".pid")
        } else {
            flag.Set("pid_file", "/var/run/"+Program+".pid")
        }
    }

    if "." == RootDir {
        RootDir = abs(filepath.Dir(os.Args[0]))
        dirs := []string{abs(filepath.Dir(os.Args[0])), filepath.Join(abs(filepath.Dir(os.Args[0])), "..")}
        for _, s := range dirs {
            if DirExists(filepath.Join(s, "conf")) {
                RootDir = s
                break
            }
        }
    } else {
        RootDir = abs(RootDir)
    }

    if !DirExists(RootDir) {
        return errors.New("root directory '" + RootDir + "' is not exist.")
    } else {
        log.Println("root directory is '" + RootDir + "'.")
    }

    e := os.Chdir(RootDir)
    if nil != e {
        log.Println("change current dir to \""+RootDir+"\",", e)
    }
    return nil
}

开发者ID:runner-mei,项目名称:daemontools,代码行数:35,代码来源:daemon.go

示例4: init

func init() {
    sdk := env.URL(nil)
    if sdk != "" {
        flag.Set("sdk", sdk)
        flag.Set("vm-path", "docker-appliance")
        flag.Set("cluster", os.Getenv("GOVC_CLUSTER"))
    }

    // fake up a docker-host for pprof collection
    u := url.URL{Scheme: "http", Host: "127.0.0.1:6060"}

    go func() {
        log.Println(http.ListenAndServe(u.Host, nil))
    }()

    transport := &http.Transport{
        TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
    }
    insecureClient = &http.Client{Transport: transport}
    flag.Set("docker-host", u.Host)

    config.hostCertFile = "fixtures/vicadmin_test_cert.pem"
    config.hostKeyFile = "fixtures/vicadmin_test_pkey.pem"

    cert, cerr := ioutil.ReadFile(config.hostCertFile)
    key, kerr := ioutil.ReadFile(config.hostKeyFile)
    if kerr != nil || cerr != nil {
        panic("unable to load test certificate")
    }
    vchConfig.HostCertificate = &vchconfig.RawCertificate{
        Cert: cert,
        Key:  key,
    }
}

开发者ID:kjplatz,项目名称:vic,代码行数:34,代码来源:vicadm_test.go

示例5: main

func main() {
    mrand.Seed(time.Now().UnixNano())
    errors := []error{
        flag.Set("logtostderr", "true"),
        flag.Set("logcolor", "true"),
    }
    for _, err := range errors {
        if err != nil {
            panic(err)
        }
    }
    lg.SetSrcHighlight("alkasir/cmd", "alkasir/pkg")
    lg.CopyStandardLogTo("info")
    flag.Parse()
    flagenv.Prefix = "ALKASIR_"
    flagenv.Parse()
    err := commandHandler(flag.Args())
    if err != nil {
        if err == errCommandNotFound {
            fmt.Println("")
            fmt.Println("Command index:")
            fmt.Println("")
            rootCommand.PrintHelp("alkasir-admin", 0)
            fmt.Println("")
            os.Exit(1)
        }
        lg.Fatal(err)
        os.Exit(1)
    }

}

开发者ID:gitter-badger,项目名称:alkasir,代码行数:31,代码来源:alkasir-admin.go

最后编辑: kuteng  文档更新时间: 2021-08-23 19:14   作者:kuteng