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

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

示例1: init

func init() {
    fileloads = make(map[int64]string)

    flag.Var(&load_opts, "ld", ld_help_str)
    flag.Var(&load_zero, "ldz", ld_help_str)
    flag.Var(&load_file, "ldf", ld_help_str)
}

开发者ID:pmallappa,项目名称:gospel,代码行数:7,代码来源:platld.go

示例2: init

func init() {
    flag.Var(&nsqdTCPAddrs, "nsqd-tcp-address", "nsqd TCP address (may be given multiple times)")
    flag.Var(&destNsqdTCPAddrs, "destination-nsqd-tcp-address", "destination nsqd TCP address (may be given multiple times)")
    flag.Var(&lookupdHTTPAddrs, "lookupd-http-address", "lookupd HTTP address (may be given multiple times)")

    flag.Var(&whitelistJSONFields, "whitelist-json-field", "for JSON messages: pass this field (may be given multiple times)")
}

开发者ID:deepglint,项目名称:nsqelastic,代码行数:7,代码来源:n2n.go

示例3: init

func init() {
    flag.BoolVar(&debug, "debug", false, "Run in debug mode")

    // The following flags need to be supported by stage1 according to
    // https://github.com/coreos/rkt/blob/master/Documentation/devel/stage1-implementors-guide.md
    // Most of them are ignored
    // These are ignored, but stage0 always passes them
    flag.Var(&discardNetlist, "net", "Setup networking")
    flag.StringVar(&discardString, "local-config", common.DefaultLocalConfigDir, "Local config path")

    // These are discarded with a warning
    // TODO either implement these, or stop passing them
    flag.Bool("interactive", true, "The pod is interactive (ignored, always true)")
    flag.Var(pkgflag.NewDiscardFlag("mds-token"), "mds-token", "MDS auth token (not implemented)")

    flag.Var(pkgflag.NewDiscardFlag("hostname"), "hostname", "Set hostname (not implemented)")
    flag.Bool("disable-capabilities-restriction", true, "ignored")
    flag.Bool("disable-paths", true, "ignored")
    flag.Bool("disable-seccomp", true, "ignored")

    dnsConfMode = pkgflag.MustNewPairList(map[string][]string{
        "resolv": {"host", "stage0", "none", "default"},
        "hosts":  {"host", "stage0", "default"},
    }, map[string]string{
        "resolv": "default",
        "hosts":  "default",
    })
    flag.Var(dnsConfMode, "dns-conf-mode", "DNS config file modes")

}

开发者ID:joshix,项目名称:rkt,代码行数:30,代码来源:main.go

示例4: main

func main() {
    // do the actual parsing
    flag.Var(&listenersFlag, "l", "Which ports to listen on")
    flag.Var(&connectorsFlag, "c", "Which addresses to try to connect to")
    flag.BoolVar(&infoptr, "v", false, "Turn on verbose mode")
    flag.BoolVar(&debugptr, "vv", false, "Turn on extra verbose mode")
    retryPeriod = time.Duration(1000 * (*flag.Float64("rp", 5.0,
        "Retry rate for double connections")))
    connPeriod = time.Duration(1000 * (*flag.Float64("cp", 0.5,
        "Retry rate for double connections, on success")))
    flag.Parse()

    debug("Number of listeners: " + fmt.Sprint(len(listenersFlag)))
    debug("Number of connectors: " + fmt.Sprint(len(connectorsFlag)))
    // check a possibly temporary condition
    if len(listenersFlag)+len(connectorsFlag) != 2 {
        errmsg(1, "Strictly 2 connections allowed")
    }

    if len(listenersFlag) == 1 && len(connectorsFlag) == 1 {
        listenOne(normalizeAddr(listenersFlag[0]),
            normalizeAddr(connectorsFlag[0]))
    }
    if len(listenersFlag) == 2 && len(connectorsFlag) == 0 {
        listenTwo(normalizeAddr(listenersFlag[0]),
            normalizeAddr(listenersFlag[1]))
    }
    if len(listenersFlag) == 0 && len(connectorsFlag) == 2 {
        connectTwo(normalizeAddr(connectorsFlag[0]),
            normalizeAddr(connectorsFlag[1]))
    }
}

开发者ID:thenoviceoof,项目名称:proxybfs,代码行数:32,代码来源:proxybfs.go

示例5: init

func init() {
    flag.BoolVar(&debug, "debug", false, "Run in debug mode")
    flag.Var(&netList, "net", "Setup networking")
    flag.BoolVar(&interactive, "interactive", false, "The pod is interactive")
    flag.StringVar(&privateUsers, "private-users", "", "Run within user namespace. Can be set to [=UIDBASE[:NUIDS]]")
    flag.StringVar(&mdsToken, "mds-token", "", "MDS auth token")
    flag.StringVar(&localConfig, "local-config", common.DefaultLocalConfigDir, "Local config path")
    flag.StringVar(&hostname, "hostname", "", "Hostname of the pod")
    flag.BoolVar(&disableCapabilities, "disable-capabilities-restriction", false, "Disable capability restrictions")
    flag.BoolVar(&disablePaths, "disable-paths", false, "Disable paths restrictions")
    flag.BoolVar(&disableSeccomp, "disable-seccomp", false, "Disable seccomp restrictions")
    dnsConfMode = pkgflag.MustNewPairList(map[string][]string{
        "resolv": {"host", "stage0", "none", "default"},
        "hosts":  {"host", "stage0", "default"},
    }, map[string]string{
        "resolv": "default",
        "hosts":  "default",
    })
    flag.Var(dnsConfMode, "dns-conf-mode", "DNS config file modes")
    flag.BoolVar(&mutable, "mutable", false, "Enable mutable operations on this pod, including starting an empty one")

    // this ensures that main runs only on main thread (thread group leader).
    // since namespace ops (unshare, setns) are done for a single thread, we
    // must ensure that the goroutine does not jump from OS thread to thread
    runtime.LockOSThread()

    localhostIP = net.ParseIP("127.0.0.1")
    if localhostIP == nil {
        panic("localhost IP failed to parse")
    }
}

开发者ID:joshix,项目名称:rkt,代码行数:31,代码来源:init.go

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