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

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

示例1: main

func main() {
    flag.Var(&patternVar, "pattern", "which add pattern")

    flag.Parse()

    patterns := []string{
        ".DS_Store",
        ".DS_Store?",
        "._*",
        ".Spotlight-V100",
        ".Trashes",
        "ehthumbs.db",
        "Thumbs.db",
    }

    if flag.NFlag() > 0 {
        for i := 0; i < len(patternVar); i++ {
            patterns = append(patterns, patternVar[i])
        }
    }

    if len(flag.Args()) == 0 {
        clean("./", patterns)
    } else {
        for _, args := range flag.Args() {
            clean(args, patterns)
        }
    }
}

开发者ID:gouvinb,项目名称:goclean,代码行数:29,代码来源:clean.go

示例2: main

func main() {
    password := flag.String("password", "", "Password for all redis instances")
    db := flag.Int("db", 0, "DB number")
    socket := flag.String("socket", "/tmp/redis-monitor.sock", "Socket to provide metrics over")
    flag.Parse()
    if len(flag.Args()) < 1 {
        flag.Usage()
        os.Exit(1)
    }
    s := &http.Server{
        Handler: &Addresses{
            Addr:     flag.Args(),
            Password: *password,
            DB:       int64(*db),
        },
    }

    l, err := util.CreateSocket(*socket)

    go func() {
        log.Println(http.ListenAndServe("localhost:6060", nil))
    }()

    defer profile.Start(profile.MemProfile).Stop()

    if err != nil {
        panic(err)
    }

    if err := s.Serve(l); err != nil {
        panic(err)
    }
}

开发者ID:mehulsbhatt,项目名称:gollector-monitors,代码行数:33,代码来源:redis-monitor.go

示例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")
}

开发者ID:denen99,项目名称:statsrelay,代码行数:60,代码来源:statsrelay.go

示例4: main

func main() {
    defer util.Run()()
    var ring *pfring.Ring
    var err error
    if ring, err = pfring.NewRing(*iface, uint32(*snaplen), pfring.FlagPromisc); err != nil {
        log.Fatalln("pfring ring creation error:", err)
    }
    if len(flag.Args()) > 0 {
        bpffilter := strings.Join(flag.Args(), " ")
        fmt.Fprintf(os.Stderr, "Using BPF filter %q\n", bpffilter)
        if err = ring.SetBPFFilter(bpffilter); err != nil {
            log.Fatalln("BPF filter error:", err)
        }
    }
    if *cluster >= 0 {
        if err = ring.SetCluster(*cluster, pfring.ClusterType(*clustertype)); err != nil {
            log.Fatalln("pfring SetCluster error:", err)
        }
    }
    if err = ring.SetSocketMode(pfring.ReadOnly); err != nil {
        log.Fatalln("pfring SetSocketMode error:", err)
    } else if err = ring.Enable(); err != nil {
        log.Fatalln("pfring Enable error:", err)
    }
    dumpcommand.Run(ring)
}

开发者ID:dazer-chen,项目名称:gopacket,代码行数:26,代码来源:main.go

示例5: 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

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