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

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

示例1: main

func main() {
    servers := flag.String("servers", "", "zk servers")
    chroot := flag.String("chroot", "", "zk chroot")
    recursive := flag.Bool("r", false, "recursive ?")
    help := flag.Bool("h", false, "help info")
    flag.Parse()
    if *help {
        printUsage()
        os.Exit(0)
    }
    if len(*servers) == 0 {
        fmt.Println("ERROR: --servers is required\n")
        printUsage()
        os.Exit(255)
    }
    if flag.NArg() < 2 {
        fmt.Println("ERROR: cmd path is requred\n")
        printUsage()
        os.Exit(255)
    }
    opt := cmd.NewCmdOption()
    opt.Servers = strings.Split(*servers, ",")
    opt.Chroot = *chroot
    opt.Recursive = *recursive
    err := cmd.Call(opt, flag.Args())
    if err != nil {
        fmt.Println("ERROR: fail to zk:", err)
        os.Exit(255)
    }
    os.Exit(0)
}

开发者ID:dzch,项目名称:zkcli,代码行数:31,代码来源:zkcli.go

示例2: main

func main() {
    algo := flag.Int("a", 256, "SHA hash algorithm (one of 256, 384, or 512)")
    check := flag.Bool("c", false, "read SHA sums from the files and check them")
    hidden := flag.Bool("d", false, "sum hidden (dot) files")
    flag.Parse()

    progName = filepath.Base(os.Args[0])
    sumHidden = *hidden

    switch *algo {
    case 1:
        sumFunc = sum1
    case 256:
        sumFunc = sum256
    case 384:
        sumFunc = sum384
    case 512:
        sumFunc = sum512
    default:
        fmt.Println("Unrecognised algorithm.")
        os.Exit(1)
    }

    if *check {
        checkFile(flag.Args())
    } else {
        for _, root := range flag.Args() {
            err := filepath.Walk(root, walker)
            if err != nil {
                fmt.Printf("%v\n", err)
            }
        }
    }
}

开发者ID:postfix,项目名称:rshasum,代码行数:34,代码来源:sum.go

示例3: main

func main() {
    swaggerDir := flag.String("path", "", "Path to model files")
    buildStructs := flag.Bool("structs", true, "Whether or not to build structs")
    buildAPI := flag.Bool("api", true, "Whether or not to build the API")
    flag.Parse()
    files, err := ioutil.ReadDir(*swaggerDir)
    if err != nil {
        log.Fatal(err)
    }
    for _, swaggerFile := range files {
        if !swaggerFile.IsDir() && strings.HasSuffix(swaggerFile.Name(), ".json") {
            apiBase := strings.TrimSuffix(swaggerFile.Name(), ".json")
            swaggerPath := strings.Join([]string{*swaggerDir, swaggerFile.Name()}, "/")
            swaggerString, err := ioutil.ReadFile(swaggerPath)
            if err != nil {
                continue
            }
            var s Swagger
            json.Unmarshal(swaggerString, &s)
            ParseModels(s.Models.(map[string]interface{}))
            BuildAPIs(apiBase, s)
        }
    }
    fmt.Println("package ari")
    if *buildAPI {
        fmt.Println(apiPreamble)
    }
    if *buildStructs {
        OutputStructs()
    }
    if *buildAPI {
        fmt.Print(clientAPIBuf.String())
    }
}

开发者ID:nvisibleinc,项目名称:go-ari-struct-builder,代码行数:34,代码来源:go-ari-struct-builder.go

示例4: main

func main() {
    cfg := flag.String("c", "cfg.json", "configuration file")
    version := flag.Bool("v", false, "show version")
    versionGit := flag.Bool("vg", false, "show version")
    flag.Parse()

    if *version {
        fmt.Println(g.VERSION)
        os.Exit(0)
    }
    if *versionGit {
        fmt.Println(g.VERSION, g.COMMIT)
        os.Exit(0)
    }

    // global config
    g.ParseConfig(*cfg)
    // proc
    proc.Start()

    // monitor
    monitor.Start()

    // http
    http.Start()

    select {}
}

开发者ID:Cepave,项目名称:anteye,代码行数:28,代码来源:main.go

示例5: main

func main() {
    debug := flag.Bool("debug", false, "debug on")
    threaded := flag.Bool("threaded", true, "debug on")
    delcache_ttl := flag.Float64("deletion_cache_ttl", 5.0, "Deletion cache TTL in seconds.")
    branchcache_ttl := flag.Float64("branchcache_ttl", 5.0, "Branch cache TTL in seconds.")
    deldirname := flag.String(
        "deletion_dirname", "GOUNIONFS_DELETIONS", "Directory name to use for deletions.")
    flag.Parse()

    if len(flag.Args()) < 2 {
        fmt.Println("Usage:\n  main MOUNTPOINT RW-DIRECTORY RO-DIRECTORY ...")
        os.Exit(2)
    }

    ufsOptions := unionfs.UnionFsOptions{
        DeletionCacheTTLSecs: *delcache_ttl,
        BranchCacheTTLSecs:   *branchcache_ttl,
        DeletionDirName:      *deldirname,
    }

    ufs, err := unionfs.NewUnionFsFromRoots(flag.Args()[1:], &ufsOptions)
    if err != nil {
        log.Fatal("Cannot create UnionFs", err)
        os.Exit(1)
    }
    mountState, _, err := fuse.MountFileSystem(flag.Arg(0), ufs, nil)
    if err != nil {
        log.Fatal("Mount fail:", err)
    }

    mountState.Debug = *debug
    mountState.Loop(*threaded)
}

开发者ID:jravasi,项目名称:go-fuse,代码行数:33,代码来源:main.go

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