本文整理汇总了Golang中flag.BoolVar函数的典型用法代码示例。如果您正苦于以下问题:Golang BoolVar函数的具体用法?Golang BoolVar怎么用?Golang BoolVar使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BoolVar函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: init
func init() {
flag.StringVar(&options.CPUProfile, "cpuprofile", "", "write cpu profile to file")
flag.Uint64Var(&options.SpoolSize, "spool-size", 1024,
"Maximum number of events to spool before a flush is forced.")
flag.IntVar(&options.NumWorkers, "num-workers", 1,
"deprecated option, strictly for backwards compatibility. does nothing.")
flag.DurationVar(&options.IdleTimeout, "idle-flush-time", 5*time.Second,
"Maximum time to wait for a full spool before flushing anyway")
flag.StringVar(&options.ConfigFile, "config", "", "The config file to load")
flag.StringVar(&options.LogFile, "log-file", "", "Log file output")
flag.StringVar(&options.PidFile, "pid-file", "lumberjack.pid",
"destination to which a pidfile will be written")
flag.BoolVar(&options.UseSyslog, "log-to-syslog", false,
"Log to syslog instead of stdout. This option overrides the --log-file option.")
flag.BoolVar(&options.FromBeginning, "from-beginning", false,
"Read new files from the beginning, instead of the end")
flag.StringVar(&options.HistoryPath, "progress-file", ".lumberjack",
"path of file used to store progress data")
flag.StringVar(&options.TempDir, "temp-dir", "/tmp",
"directory for creating temp files")
flag.IntVar(&options.NumThreads, "threads", 1, "Number of OS threads to use")
flag.IntVar(&options.CmdPort, "cmd-port", 42586, "tcp command port number")
flag.StringVar(&options.HttpPort, "http", "",
"http port for debug info. No http server is run if this is left off. E.g.: http=:6060")
}
示例2: initFlags
func initFlags() {
certPath := filepath.Join(os.Getenv("DOCKER_CERT_PATH"))
if certPath == "" {
certPath = filepath.Join(os.Getenv("HOME"), ".docker")
}
flag.BoolVar(&version, "version", false, "show version")
flag.BoolVar(&watch, "watch", false, "watch for container changes")
flag.BoolVar(&onlyExposed, "only-exposed", false, "only include containers with exposed ports")
flag.BoolVar(&onlyPublished, "only-published", false,
"only include containers with published ports (implies -only-exposed)")
flag.StringVar(¬ifyCmd, "notify", "", "run command after template is regenerated (e.g `restart xyz`)")
flag.StringVar(¬ifySigHUPContainerID, "notify-sighup", "",
"send HUP signal to container. Equivalent to `docker kill -s HUP container-ID`")
flag.Var(&configFiles, "config", "config files with template directives. Config files will be merged if this option is specified multiple times.")
flag.IntVar(&interval, "interval", 0, "notify command interval (secs)")
flag.StringVar(&endpoint, "endpoint", "", "docker api endpoint (tcp|unix://..). Default unix:///var/run/docker.sock")
flag.StringVar(&tlsCert, "tlscert", filepath.Join(certPath, "cert.pem"), "path to TLS client certificate file")
flag.StringVar(&tlsKey, "tlskey", filepath.Join(certPath, "key.pem"), "path to TLS client key file")
flag.StringVar(&tlsCaCert, "tlscacert", filepath.Join(certPath, "ca.pem"), "path to TLS CA certificate file")
flag.BoolVar(&tlsVerify, "tlsverify", os.Getenv("DOCKER_TLS_VERIFY") != "", "verify docker daemon's TLS certicate")
flag.Usage = usage
flag.Parse()
}
示例3: main
func main() {
var bindAddress string
var port int
flag.IntVar(&port, "port", 9125, "Port to listen on")
flag.IntVar(&port, "p", 9125, "Port to listen on")
flag.StringVar(&bindAddress, "bind", "0.0.0.0", "IP Address to listen on")
flag.StringVar(&bindAddress, "b", "0.0.0.0", "IP Address to listen on")
flag.StringVar(&prefix, "prefix", "statsrelay", "The prefix to use with self generated stats")
flag.BoolVar(&verbose, "verbose", false, "Verbose output")
flag.BoolVar(&verbose, "v", false, "Verbose output")
flag.Parse()
if len(flag.Args()) == 0 {
log.Fatalf("One or most host specifications are needed to locate statsd daemons.\n")
}
hashRing = consistent.New()
hashRing.NumberOfReplicas = 1
for _, v := range flag.Args() {
var addr *net.UDPAddr
var err error
host := strings.Split(v, ":")
switch len(host) {
case 1:
log.Printf("Invalid statsd location: %s\n", v)
log.Fatalf("Must be of the form HOST:PORT or HOST:PORT:INSTANCE\n")
case 2:
addr, err = net.ResolveUDPAddr("udp", v)
if err != nil {
log.Printf("Error parsing HOST:PORT \"%s\"\n", v)
log.Fatalf("%s\n", err.Error())
}
case 3:
addr, err = net.ResolveUDPAddr("udp", host[0]+":"+host[1])
if err != nil {
log.Printf("Error parsing HOST:PORT:INSTANCE \"%s\"\n", v)
log.Fatalf("%s\n", err.Error())
}
default:
log.Fatalf("Unrecongnized host specification: %s\n", v)
}
if addr != nil {
udpAddr[v] = addr
hashRing.Add(v)
}
}
epochTime = time.Now().Unix()
runServer(bindAddress, port)
log.Printf("Normal shutdown.\n")
}
示例4: setOptions
func (c *cover) setOptions() {
flag.BoolVar(&c.set, "cover", false, "Use the cover tool.")
flag.BoolVar(&c.open, "open", true,
"Open the results of the cover tool on the browser.")
flag.Float64Var(&c.threshold,
"threshold", defaultThreshold, "The accepted code coverage threshold.")
}
示例5: parseArgs
func parseArgs() args {
var a args
// setup + parse flags
flag.BoolVar(&a.listen, "listen", false, "listen for connections")
flag.BoolVar(&a.listen, "l", false, "listen for connections (short)")
flag.BoolVar(&a.verbose, "v", false, "verbose debugging")
flag.Usage = Usage
flag.Parse()
osArgs := flag.Args()
if len(osArgs) < 1 {
exit("")
}
if a.listen {
a.localAddr = osArgs[0]
} else {
if len(osArgs) > 1 {
a.localAddr = osArgs[0]
a.remoteAddr = osArgs[1]
} else {
a.remoteAddr = osArgs[0]
}
}
return a
}
示例6: parseFlags
func parseFlags() error {
flag.BoolVar(&flagA, "a", flagA, "see 'go build' help")
flag.BoolVar(&flagX, "x", flagX, "see 'go build' help")
flag.BoolVar(&flagRace, "race", flagRace, "see 'go build' help")
flag.StringVar(&flagTags, "tags", flagTags, "see 'go build' help")
flag.BoolVar(&flagV, "v", flagV, "see 'go test' help")
flag.IntVar(&flagCount, "count", flagCount, "see 'go test' help")
flag.StringVar(&flagCPU, "cpu", flagCPU, "see 'go test' help")
flag.StringVar(&flagParallel, "parallel", flagParallel, "see 'go test' help")
flag.StringVar(&flagRun, "run", flagRun, "see 'go test' help")
flag.BoolVar(&flagShort, "short", flagShort, "see 'go test' help")
flag.StringVar(&flagTimeout, "timeout", flagTimeout, "see 'go test' help")
flag.StringVar(&flagCoverMode, "covermode", flagCoverMode, "see 'go test' help")
flag.StringVar(&flagCoverProfile, "coverprofile", flagCoverProfile, "see 'go test' help")
flag.IntVar(&flagParallelPackages, "parallelpackages", flagParallelPackages, "Number of package test run in parallel")
flag.Parse()
if flagCoverProfile == "" {
flagCoverProfile = "out.coverprofile"
}
if flagParallelPackages < 1 {
return fmt.Errorf("flag parallelpackages must be greater than or equal to 1")
}
return nil
}
示例7: init
func init() {
flag.StringVar(&configFile, "c", "config.json", "the config file")
flag.BoolVar(&version, "V", false, "show version")
flag.BoolVar(&testMode, "t", false, "test config")
flag.IntVar(&statPort, "s", -1, "set stat server port")
flag.IntVar(&commitInterval, "i", 10, "set stat server port")
}
示例8: main
func main() {
var quiet bool
var dontResolveSymlinks bool
flag.BoolVar(&quiet, "q", false, "warnings will not be printed")
flag.BoolVar(&dontResolveSymlinks, "s", false, "do not resolve symlink")
flag.Parse()
for _, path := range flag.Args() {
s, err := filepath.Abs(path)
if err != nil {
if !quiet {
fmt.Fprintln(os.Stderr, err)
}
continue
}
if !dontResolveSymlinks {
s, err = filepath.EvalSymlinks(s)
if err != nil {
if !quiet {
fmt.Fprintln(os.Stderr, err)
}
continue
}
}
fmt.Println(s)
}
}
示例9: init
func init() {
// Read configuration from files
read_configurations()
// Now override configuration with command line parameters
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0])
flag.PrintDefaults()
fmt.Fprintf(os.Stderr, "\n")
fmt.Fprintf(os.Stderr, "The following configuration files will also be read:")
fmt.Fprintf(os.Stderr, " (+ if file is present)\n")
for _, file := range config_files() {
if _, err := os.Stat(file); os.IsNotExist(err) {
fmt.Fprintf(os.Stderr, " - %s\n", file)
} else {
fmt.Fprintf(os.Stderr, " + %s\n", file)
}
}
}
flag.StringVar(&cfg.Channel, "c", cfg.Channel, "Post input values to specified channel or user.")
flag.StringVar(&cfg.IconURL, "i", cfg.IconURL, "This url is used as icon for posting.")
flag.StringVar(&cfg.Language, "l", cfg.Language, "Specify the language used for syntax highlighting (ruby/python/...)")
flag.StringVar(&cfg.MatterURL, "m", cfg.MatterURL, "Mattermost incoming webhooks URL.")
flag.StringVar(&cfg.Title, "t", cfg.Title, "This title is added to posts. (not with -n)")
flag.StringVar(&cfg.Username, "u", cfg.Username, "This username is used for posting.")
flag.BoolVar(&cfg.Extra, "x", cfg.Extra, "Add extra info (user/hostname/timestamp).")
flag.BoolVar(&cfg.NoBuffer, "n", cfg.NoBuffer, "Post input values without buffering.")
flag.BoolVar(&cfg.PlainText, "p", cfg.PlainText, "Don't surround the post with triple backticks.")
flag.BoolVar(&flagVersion, "version", false, "show version.")
flag.Parse()
}
示例10: main
func main() {
flag.BoolVar(&fotki.Verbose, "v", false, "Be verbose")
flag.BoolVar(&fotki.DryRun, "n", false, "Dry-run")
flag.BoolVar(&fotki.Rescan, "rescan", false, "Rescan valid directories under root")
flag.BoolVar(&fotki.RemoveOld, "move", false, "Remove the original files")
scandir := flag.String("scan", "", "The directory to scan")
rootdir := flag.String("root", "", "The root directory of the album")
flag.Parse()
if fotki.Verbose {
fmt.Println("# scandir=", *scandir)
fmt.Println("# rootdir=", *rootdir)
}
if *scandir == "" {
fmt.Fprintln(os.Stderr, "scan flag is required")
os.Exit(1)
}
if *rootdir == "" {
fmt.Fprintln(os.Stderr, "root flag is required")
os.Exit(1)
}
album := fotki.NewAlbum(*rootdir)
check(album.Scan(*scandir))
check(album.Relocate())
album.ShowFailed()
}
示例11: init
func init() {
flag.StringVar(&Options.Zone, "z", "", "zone")
flag.BoolVar(&Options.ShowVersion, "v", false, "show version and exit")
flag.BoolVar(&Options.ShowVersion, "version", false, "show version and exit")
flag.StringVar(&Options.LogFile, "log", "stdout", "log file")
flag.StringVar(&Options.LogLevel, "level", "debug", "log level")
flag.IntVar(&Options.LogRotateSize, "logsize", 10<<30, "max unrotated log file size")
flag.StringVar(&Options.InfluxAddr, "influxaddr", "", "influxdb server addr")
flag.StringVar(&Options.ManagerType, "man", "dummy", "manager type <dummy|mysql>")
flag.StringVar(&Options.InfluxDbname, "influxdb", "", "influxdb db name")
flag.StringVar(&Options.ListenAddr, "addr", ":9065", "monitor http server addr")
flag.StringVar(&Options.HintedHandoffDir, "hhdirs", "hh", "hinted handoff dirs seperated by comma")
flag.Parse()
if Options.ShowVersion {
fmt.Fprintf(os.Stderr, "%s-%s\n", gafka.Version, gafka.BuildId)
os.Exit(0)
}
if Options.Zone == "" {
panic("empty zone not allowed")
}
golog.SetOutput(ioutil.Discard)
if Options.LogFile != "stdout" {
SetupLogging(Options.LogFile, Options.LogLevel, "panic")
} else {
SetupLogging(Options.LogFile, Options.LogLevel, "")
}
ctx.LoadFromHome()
}
示例12: main
func main() {
flag.BoolVar(&CmdlineOptions.Verbose, "v", false, "Verbose")
flag.BoolVar(&CmdlineOptions.WaitForEvent, "w", false, "For commands that return an event_id, wait for the event to complete.")
InitRoutingTable()
flag.Parse()
route := FindMatchingRoute(flag.Args())
if CmdlineOptions.Verbose {
fmt.Fprintf(os.Stderr, "Args: %s\n", flag.Args())
}
if CmdlineOptions.Verbose {
fmt.Fprintf(os.Stderr, "Route: %s\n", route)
}
if route == nil {
fmt.Fprintf(os.Stderr, "Error: unrecognized command: %s\n", flag.Args())
ShowGeneralHelp(route)
os.Exit(1)
}
if !InitConfig() {
fmt.Fprintf(os.Stderr, "Invalid or Missing configuration file.\n")
os.Exit(1)
}
if CmdlineOptions.Verbose {
fmt.Fprintf(os.Stderr, "Config: %s\n", Config)
}
if route != nil {
if CmdlineOptions.Verbose {
fmt.Fprintf(os.Stderr, "Calling route: %s\n", route)
}
route.Handler(route)
}
}
示例13: main
func main() {
var pubFile, privFile string
var help, listen, stayOpen bool
flag.BoolVar(&help, "h", false, "display a short usage message")
flag.BoolVar(&stayOpen, "k", false, "keep listening after client disconnects")
flag.BoolVar(&listen, "l", false, "listen for incoming connections")
flag.StringVar(&privFile, "s", "", "path to signature key")
flag.StringVar(&pubFile, "v", "", "path to verification key")
flag.Parse()
if help {
usage()
os.Exit(1)
}
loadID(privFile, pubFile)
defer func() {
if idPriv != nil {
zero(idPriv[:], 0)
}
}()
if listen {
if flag.NArg() != 1 {
fmt.Println("A port is required (and should be the only argument) when listening.")
}
listener(stayOpen, flag.Arg(0))
return
}
if flag.NArg() != 2 {
fmt.Println("An address and port are required (and should be the only arguments).")
}
sender(flag.Arg(0) + ":" + flag.Arg(1))
}
示例14: parseArgs
func parseArgs() args {
var a args
// setup + parse flags
flag.BoolVar(&a.listen, "listen", false, "listen for connections")
flag.BoolVar(&a.listen, "l", false, "listen for connections (short)")
flag.BoolVar(&a.verbose, "v", true, "verbose")
flag.BoolVar(&a.debug, "debug", false, "debugging")
// flag.StringVar(&a.keyfile, "key", "", "private key file")
flag.IntVar(&a.keybits, "keybits", 2048, "num bits for generating private key")
flag.Usage = Usage
flag.Parse()
osArgs := flag.Args()
if len(osArgs) < 1 {
exit("")
}
if a.verbose {
out("verbose on")
}
if a.listen {
a.localAddr = osArgs[0]
} else {
if len(osArgs) > 1 {
a.localAddr = osArgs[0]
a.remoteAddr = osArgs[1]
} else {
a.remoteAddr = osArgs[0]
}
}
return a
}
示例15: init
func init() {
potentialQueues := os.Getenv("WORKER_QUEUES")
potentialConcurrency := os.Getenv("WORKER_CONCURRENCY")
concurrency = 25
if potentialConcurrency != "" {
tmp, _ := strconv.ParseInt(potentialConcurrency, 10, 32)
concurrency = int(tmp)
}
flag.StringVar(&queuesString, "queues", potentialQueues, "a comma-separated list of Resque queues")
flag.Float64Var(&intervalFloat, "interval", 5.0, "sleep interval when no jobs are found")
flag.IntVar(&concurrency, "concurrency", concurrency, "the maximum number of concurrently executing jobs")
flag.IntVar(&connections, "connections", 2, "the maximum number of connections to the Redis database")
redisProvider := os.Getenv("REDIS_PROVIDER")
var redisEnvUri string
if redisProvider != "" {
redisEnvUri = os.Getenv(redisProvider)
} else {
redisEnvUri = os.Getenv("REDIS_URL")
}
if redisEnvUri == "" {
redisEnvUri = "redis://localhost:6379/"
}
flag.StringVar(&uri, "uri", redisEnvUri, "the URI of the Redis server")
flag.StringVar(&namespace, "namespace", "resque:", "the Redis namespace")
flag.BoolVar(&exitOnComplete, "exit-on-complete", false, "exit when the queue is empty")
flag.BoolVar(&useNumber, "use-number", false, "use json.Number instead of float64 when decoding numbers in JSON. will default to true soon")
}