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

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

示例1: init

func init() {
    flag.StringVar(&Package, "p", "atomap", "package name")
    flag.StringVar(&Key, "k", "int", "key type")
    flag.StringVar(&Value, "v", "int", "value type")
    flag.StringVar(&File, "f", "atomap.go", "file name")
    flag.Parse()
}

开发者ID:Jxck,项目名称:AtoMap,代码行数:7,代码来源:generate.go

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

示例3: init

func init() {
    flag.IntVar(&N, "N", 100, "Matrix rows/cols.")

    // blocking size; 0 is unblocked versions
    flag.IntVar(&KB, "KB", 0, "Blocking size for blocked invocations")

    // parameters for basic matrix operations
    flag.IntVar(&MB, "MB", 68, "Row blocking size.")
    flag.IntVar(&NB, "NB", 68, "Column blocking size.")
    flag.IntVar(&VPsize, "H", 68, "Viewport size.")
    flag.IntVar(&nWorker, "W", 2, "Number of workers for parallel runs")

    flag.BoolVar(&singleTest, "s", false, "Run single test run for given matrix size.")
    flag.BoolVar(&refTest, "r", false, "Test with lapack reference function.")
    flag.StringVar(&sizeList, "L", "", "Comma separated list of matrix sizes.")
    flag.IntVar(&testCount, "n", 5, "Number of test runs.")

    flag.BoolVar(&noSPD, "-nP", false, "Matrix is not SPD.")
    flag.BoolVar(&testUpper, "U", false, "Matrix is UPPER triangular. ")
    flag.BoolVar(&check, "C", false, "Check result against lapack reference.")
    flag.BoolVar(&verbose, "v", false, "Be verbose.")
    flag.BoolVar(&asGflops, "g", false, "Report as Gflops.")
    flag.BoolVar(&asEps, "e", false, "Report as result elements per seconds.")
    flag.StringVar(&testName, "T", "test", "Test name for reporting")
    flag.StringVar(&fileName, "F", "saved.dat", "Filename for source data")
}

开发者ID:hrautila,项目名称:matops,代码行数:26,代码来源:perf_chol.go

示例4: main

func main() {
    var url, origin string
    flag.StringVar(&url, "url", "ws://127.0.0.1:9999/echo", "websocket URL")
    flag.StringVar(&origin, "origin", "http://localhost/", "origin header")
    flag.Parse()

    if url == "" {
        flag.Usage()
        os.Exit(1)
    }

    ws, err := websocket.Dial(url, "", origin)
    if err != nil {
        log.Fatal(err)
    }

    go func() {
        var msg = make([]byte, 512)
        for {
            n, err := ws.Read(msg)
            if err != nil {
                log.Fatal(err)
            }
            fmt.Printf("R: %s\nS: ", msg[:n])
        }
    }()

    fmt.Print("S: ")
    sc := bufio.NewScanner(os.Stdin)
    for sc.Scan() {
        if _, err := ws.Write(sc.Bytes()); err != nil {
            log.Fatal(err)
        }
    }
}

开发者ID:jamesbjackson,项目名称:fabio,代码行数:35,代码来源:wsclient.go

示例5: main

func main() {
    flag.StringVar(&url, "u", "", "URL to load test (required)")
    flag.StringVar(&method, "m", "GET", "HTTP method")
    flag.UintVar(&concurrency, "c", 10, "number of concurrent requests")
    flag.UintVar(&requests, "n", 1000, "number of total requests to make")
    flag.UintVar(&timeout, "t", 15, "request timeout in seconds")
    flag.StringVar(&regions, "r", "us-east-1,eu-west-1,ap-northeast-1", "AWS regions to run in (comma separated, no spaces)")
    flag.Parse()

    if url == "" {
        flag.Usage()
        os.Exit(0)
    }

    test, testerr := goad.NewTest(&goad.TestConfig{
        URL:            url,
        Concurrency:    concurrency,
        TotalRequests:  requests,
        RequestTimeout: time.Duration(timeout) * time.Second,
        Regions:        strings.Split(regions, ","),
        Method:         method,
    })
    if testerr != nil {
        fmt.Println(testerr)
        os.Exit(1)
    }

    var finalResult queue.RegionsAggData
    defer printSummary(&finalResult)

    sigChan := make(chan os.Signal, 1)
    signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM) // but interrupts from kbd are blocked by termbox

    start(test, &finalResult, sigChan)
}

开发者ID:ernesto-jimenez,项目名称:goad,代码行数:35,代码来源:cli.go

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