当前位置: 首页>>代码示例>>Golang>>正文


Golang flag.Var函数代码示例

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


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

示例6: init

func init() {
	flag.StringVar(&FlagAddr, "mpi-addr", "", "address of the local running process")
	flag.Var(&FlagAllAddrs, "mpi-alladdr", "addresses of all of the processes as comma separated values")
	flag.Var(&FlagInitTimeout, "mpi-inittimeout", "duration to wait before timeout in init")
	flag.StringVar(&FlagProtocol, "mpi-protocol", "tcp", "communication protocol to use")
	flag.StringVar(&FlagPassword, "mpi-password", "", "value to use for salting the mpi connection")
}
开发者ID:gersakbogdan,项目名称:mpi,代码行数:7,代码来源:flags.go

示例7: parseFlags

func parseFlags() *stage1commontypes.RuntimePod {
	rp := stage1commontypes.RuntimePod{}

	flag.BoolVar(&debug, "debug", false, "Run in debug mode")
	flag.BoolVar(&interactive, "interactive", false, "The pod is interactive")
	flag.StringVar(&localConfig, "local-config", common.DefaultLocalConfigDir, "Local config path")

	// These flags are persisted in the PodRuntime
	flag.BoolVar(&rp.Mutable, "mutable", false, "Enable mutable operations on this pod, including starting an empty one")
	flag.Var(&rp.NetList, "net", "Setup networking")
	flag.StringVar(&rp.PrivateUsers, "private-users", "", "Run within user namespace. Can be set to [=UIDBASE[:NUIDS]]")
	flag.StringVar(&rp.MDSToken, "mds-token", "", "MDS auth token")
	flag.StringVar(&rp.Hostname, "hostname", "", "Hostname of the pod")
	flag.BoolVar(&rp.InsecureOptions.DisableCapabilities, "disable-capabilities-restriction", false, "Disable capability restrictions")
	flag.BoolVar(&rp.InsecureOptions.DisablePaths, "disable-paths", false, "Disable paths restrictions")
	flag.BoolVar(&rp.InsecureOptions.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.Parse()

	rp.Debug = debug
	rp.ResolvConfMode = dnsConfMode.Pairs["resolv"]
	rp.EtcHostsMode = dnsConfMode.Pairs["hosts"]

	return &rp
}
开发者ID:intelsdi-x,项目名称:rkt,代码行数:33,代码来源:init.go

示例8: init

func init() {
	flag.Var(&address, "address", "The IP address on to serve on (set to 0.0.0.0 for all interfaces)")
	flag.Var(&etcdServerList, "etcd_servers", "List of etcd servers to watch (http://ip:port), comma separated. Mutually exclusive with -etcd_config")
	flag.Var(&corsAllowedOriginList, "cors_allowed_origins", "List of allowed origins for CORS, comma separated.  An allowed origin can be a regular expression to support subdomain matching.  If this list is empty CORS will not be enabled.")
	flag.Var(&portalNet, "portal_net", "A CIDR notation IP range from which to assign portal IPs. This must not overlap with any IP ranges assigned to nodes for pods.")
	client.BindKubeletClientConfigFlags(flag.CommandLine, &kubeletConfig)
}
开发者ID:TencentSA,项目名称:kubernetes-0.5,代码行数:7,代码来源:apiserver.go

示例9: init

func init() {
	flag.Var(&skips, "skip", "skip test case")
	flag.Var(&cases, "case", "run test case")
	flag.BoolVar(&Debug, "debug", false, "enter debug mode")

	log.SetFlags(log.Lshortfile | log.LstdFlags)
}
开发者ID:bom-d-van,项目名称:sidekick,代码行数:7,代码来源:sidekick.go

示例10: init

func init() {
	var (
		configureFile string
		printVersion  bool
	)

	flag.StringVar(&configureFile, "C", "", "configure file")
	flag.Var(&options.ChainNodes, "F", "forward address, can make a forward chain")
	flag.Var(&options.ServeNodes, "L", "listen address, can listen on multiple ports")
	flag.BoolVar(&printVersion, "V", false, "print version")
	flag.Parse()

	if err := loadConfigureFile(configureFile); err != nil {
		glog.Fatal(err)
	}

	if glog.V(5) {
		http2.VerboseLogs = true
	}

	if flag.NFlag() == 0 {
		flag.PrintDefaults()
		return
	}

	if printVersion {
		fmt.Fprintf(os.Stderr, "GOST %s (%s)\n", gost.Version, runtime.Version())
		return
	}
}
开发者ID:guest6379,项目名称:gost,代码行数:30,代码来源:main.go

示例11: init

func init() {
	flag.Var(&in, "in", "comma separated pair of BAM files to be processed.")
	flag.StringVar(&ref, "ref", "", "fasta file of the genome to be processed.")
	flag.StringVar(&annot, "annot", "", "file name of a GFF file containing annotations.")
	flag.Var(&classes, "class", "comma separated set of annotation classes to analyse.")
	flag.StringVar(&out, "out", "", "outfile name.")
	flag.BoolVar(&pretty, "pretty", true, "outfile JSON data indented.")
	flag.BoolVar(&denest, "denest", false, "only consider denested reads for support count.")
	flag.IntVar(&minLength, "min", 20, "minimum length read considered.")
	flag.IntVar(&maxLength, "max", 35, "maximum length read considered.")
	flag.IntVar(&minId, "minid", 90, "minimum percentage identity for mapped bases.")
	flag.IntVar(&minQ, "minQ", 20, "minimum per-base sequence quality.")
	flag.IntVar(&filter, "f", 0, "filter on piwi type 0: no filter, 1: primary, 2: secondary.")
	flag.Float64Var(&minAvQ, "minAvQ", 30, "minimum average per-base sequence quality.")
	flag.IntVar(&mapQ, "mapQ", 0, "minimum mapping quality [0, 255).")
	flag.IntVar(&binLength, "bin", 1e7, "bin length.")
	help := flag.Bool("help", false, "output this usage message.")
	flag.Parse()
	mapQb = byte(mapQ)
	if *help {
		flag.Usage()
		os.Exit(0)
	}
	if in[0] == "" || in[1] == "" || out == "" || !annotOK(annot, classes) || mapQ < 0 || mapQ > 254 {
		flag.Usage()
		os.Exit(1)
	}
}
开发者ID:henmt,项目名称:2015,代码行数:28,代码来源:length-heat-annot-diff.go

示例12: main

func main() {
	flag.BoolVar(&fflag, "f", false, "unlink any already existing file, permitting the link to occur")
	flag.BoolVar(&hflag, "h", false, "if the target is a symlink to a directory, do not descend to it")
	flag.BoolVar(&hflag, "n", false, "alias for -h for compatibility")
	flag.BoolVar(&sflag, "s", false, "create a symbolic link")
	flag.Var(symFlag('L'), "L", "when creating a hard link and the source is a symbolic link, link to the fully resolved target of symbolic link")
	flag.Var(symFlag('P'), "P", "when creating a hardlink and the source is a symbolic link, link to the symbolic link itself")
	flag.Usage = usage
	flag.Parse()

	switch flag.NArg() {
	case 0:
		usage()
	case 1:
		ek(ln(flag.Arg(0), ".", true))
	case 2:
		ek(ln(flag.Arg(0), flag.Arg(1), false))
	default:
		sourceDir := flag.Arg(flag.NArg() - 1)
		fi, err := os.Stat(sourceDir)
		ck(err)

		if !fi.IsDir() {
			usage()
		}

		args := flag.Args()
		for _, name := range args[:len(args)-1] {
			ek(ln(name, sourceDir, true))
		}
	}

	os.Exit(status)
}
开发者ID:qeedquan,项目名称:misc_utilities,代码行数:34,代码来源:ln.go

示例13: parseOptions

// Parses service options from the command line
func parseOptions() (*serviceOptions, error) {
	options := &serviceOptions{}

	flag.StringVar(&options.codePath, "js", "", "Js code path")
	flag.StringVar(&options.backend, "b", "memory", "Backend type e.g. 'cassandra' or 'memory'")
	flag.StringVar(&options.loadBalancer, "lb", "random", "Loadbalancer algo, e.g. 'random'")

	flag.StringVar(&options.host, "h", "localhost", "Host to bind to")
	flag.IntVar(&options.httpPort, "p", 8080, "HTTP port to bind to")

	flag.StringVar(&options.pidPath, "pid", "", "pid file path")

	flag.Var(&options.cassandraServers, "csnode", "Cassandra nodes to connect to")
	flag.StringVar(&options.cassandraKeyspace, "cskeyspace", "", "Cassandra keyspace")

	flag.BoolVar(&options.cassandraCleanup, "cscleanup", false, "Whethere to perform periodic cassandra cleanups")
	flag.Var(&options.cassandraCleanupOptions, "cscleanuptime", "Cassandra cleanup utc time of day in form: HH:MM")

	flag.DurationVar(&options.cleanupPeriod, "logcleanup", time.Duration(24)*time.Hour, "How often should we remove unused golang logs (e.g. 24h, 1h, 7h)")

	flag.StringVar(&options.discovery, "discovery", "disabled", "Discovery Backend e.g. 'disabled', 'rackspace://${USERNAME}:${API_KEY}', or 'etcd")
	flag.Var(&options.etcdEndpoints, "etcd", "Etcd discovery service API endpoints")

	flag.StringVar(&options.sslCertFile, "sslcert", "", "File containing SSL Certificates")
	flag.StringVar(&options.sslKeyFile, "sslkey", "", "File containing SSL Private Key")

	flag.StringVar(&options.metricsOutput, "metrics", "console", "Comma seperated list of where to send metrics.")
	flag.StringVar(&options.cpuProfile, "cpuprofile", "", "Run with CPU Profiling enabled.")

	flag.Parse()

	return options, nil
}
开发者ID:karlpilkington,项目名称:golang-devops-stuff,代码行数:34,代码来源:options.go

示例14: init

func init() {
	flag.Var(&Aliases, "D", "Replace text with some other text")
	flag.Var(&Headers, "H", "Request headers")
	flag.StringVar(&fileName, "filename", "", "File containing list of test rules")

	flag.Parse()
}
开发者ID:rawoke083,项目名称:RestTest,代码行数:7,代码来源:rtest.go

示例15: main

func main() {
	templates := templateList{}
	flag.Var(&templates, "t", "Specify template and append optional destination after collons. Format: foo.tmpl:/etc/foo.conf")
	flag.Var(&keepEnvs, "e", fmt.Sprintf("Keep specified environment variables beside %s", strings.Join(keepEnvs, ",")))
	flag.Parse()
	if *root == "" {
		r, err := os.Getwd()
		if err != nil {
			log.Fatal("Not root (-r) specified and couldn't get working directory")
		}
		*root = r
	}
	args := flag.Args()
	if len(args) == 0 {
		log.Fatal("No command provided, exiting")
	}

	if err := templates.Render(*root); err != nil {
		log.Fatal(err)
	}
	path, err := exec.LookPath(args[0])
	if err != nil {
		log.Fatal(err)
	}
	if *keepAllEnvs {
		execEnv = os.Environ()
	} else {
		execEnv = getFilteredEnv(keepEnvs)
	}
	if err := syscall.Exec(path, args, execEnv); err != nil {
		log.Fatal(err)
	}
}
开发者ID:HowardMei,项目名称:reefer,代码行数:33,代码来源:main.go


注:本文中的flag.Var函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。