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

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

示例1: decodeRefArg

func decodeRefArg(name, typeName string) (interface{}, error) {
    switch strings.ToLower(typeName) {
    case "*bool":
        newValue := flag.Bool(name, app.DefaultBoolValue, name)
        return newValue, nil
    case "bool":
        newValue := flag.Bool(name, app.DefaultBoolValue, name)
        return *newValue, nil

    case "*string":
        newValue := flag.String(name, app.DefaultStringValue, name)
        return *newValue, nil
    case "string":
        newValue := flag.String(name, app.DefaultStringValue, name)
        return *newValue, nil

    case "*time.duration":
        newValue := flag.Duration(name, app.DefaultDurationValue, name)
        return *newValue, nil
    case "time.duration":
        newValue := flag.Duration(name, app.DefaultDurationValue, name)
        return *newValue, nil

    case "*float64":
        newValue := flag.Float64(name, app.DefaultFloat64Value, name)
        return *newValue, nil
    case "float64":
        newValue := flag.Float64(name, app.DefaultFloat64Value, name)
        return *newValue, nil

    case "*int":
        newValue := flag.Int(name, app.DefaultIntValue, name)
        return *newValue, nil
    case "int":
        newValue := flag.Int(name, app.DefaultIntValue, name)
        return *newValue, nil

    case "*int64":
        newValue := flag.Int64(name, app.DefaultInt64Value, name)
        return *newValue, nil
    case "int64":
        newValue := flag.Int64(name, app.DefaultInt64Value, name)
        return *newValue, nil

    case "*uint":
        newValue := flag.Uint(name, app.DefaultUIntValue, name)
        return *newValue, nil
    case "uint":
        newValue := flag.Uint(name, app.DefaultUIntValue, name)
        return *newValue, nil

    case "*uint64":
        newValue := flag.Uint64(name, app.DefaultUInt64Value, name)
        return *newValue, nil
    case "uint64":
        newValue := flag.Uint64(name, app.DefaultUInt64Value, name)
        return *newValue, nil
    }
    return nil, fmt.Errorf("unknow type %s for argument %s", typeName, name)
}

开发者ID:goatcms,项目名称:goat-core,代码行数:60,代码来源:injector.go

示例2: main

func main() {
    maxPics := flag.Int64("max", -1, "Max count of pics to download (not implemented)")
    downloaders := flag.Uint64("dl", 1, "Number of simultaneous manga downloader")
    workers := flag.Uint64("worker", 3, "Number of simultaneous archive worker per downloader")
    fetchers := flag.Uint64("fetch", 4, "Number of simultaneous image fetcher per worker")
    flag.Parse()
    mangas := flag.Args()

    targets := make(chan uint64, len(mangas))

    logfile, err := os.OpenFile("log.txt", os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0666)
    if err != nil {
        return
    }
    defer logfile.Close()
    logfile.WriteString(fmt.Sprintf(`======================================================
Fetch started at %v
======================================================
Targets supplied: %v
`, time.Now(), mangas))
    log.SetOutput(io.MultiWriter(os.Stdout, logfile))

    for _, manga := range mangas {
        m, err := strconv.ParseUint(manga, 10, 64)
        if err != nil {
            log.Fatal(err)
        }
        log.Println("Adding download target:", m)
        targets <- m
    }

    if len(mangas) == 0 {
        fmt.Println("Please input space-seperated manga ID.")
        fmt.Println("Manga ID: http://marumaru.in/b/manga/{ID}")
        os.Exit(1)
    }

    if *fetchers == 0 || *workers == 0 || *maxPics == 0 || *downloaders == 0 {
        fmt.Println("Invalid argument supplied")
        os.Exit(1)
    }
    doc, err := goquery.NewDocument(MangaPrefix)
    if err == nil && doc.Find("title").First().Text()[:7] == "You are" {
        UpdateCookie(doc)
    }
    wg := new(sync.WaitGroup)
    wg.Add(int(*downloaders))
    for i := uint64(0); i < *downloaders; i++ {
        dl := new(Downloader)
        dl.Init(*workers, *fetchers, *maxPics)
        go dl.Start(targets, wg)
    }
    close(targets)
    wg.Wait()
    log.Print("All tasks were done.")
}

开发者ID:Team-IVIag,项目名称:IVIag-go,代码行数:56,代码来源:iviag.go

示例3: main

func main() {
    duration := flag.Uint64("duration", 3600, "Time to sleep before exit")
    asn := flag.Uint64("ASN", 65101, "Our AS number")
    rid := flag.Uint64("RID", 1, "Our router's ID")
    cfg := flag.String("cfg", "./inj.cfg", "Our configuration file")
    flag.Parse()
    fmt.Println("starting to inject bgp routes")
    to := make(chan bgp2go.BGPProcessMsg)
    from := make(chan bgp2go.BGPProcessMsg)
    bgpContext := bgp2go.BGPContext{ASN: uint32(*asn), RouterID: uint32(*rid)}
    go bgp2go.StartBGPProcess(to, from, bgpContext)
    ReadFile(*cfg, to)
    time.Sleep(time.Duration(*duration) * time.Second)
    fmt.Println("i've slept enough. waking up...")
}

开发者ID:tehnerd,项目名称:bgpinjector,代码行数:15,代码来源:main.go

示例4: main

func main() {
    // use [from/to/by] or [from/iterations]
    nFrom := flag.Uint64("from", 1e2, "start iterations from this number")
    nTo := flag.Uint64("to", 1e4, "run iterations until arriving at this number")
    nBy := flag.Uint64("by", 1, "increment each iteration by this number")
    nIncrements := flag.Uint64("iterations", 0, "number of iterations to execute")
    encodingType := flag.String("encoding", "string", "encode/decode as 'string', 'binary', 'binary-int', 'binary-varint'")
    flag.Parse()

    flag.Usage = func() {
        fmt.Printf("%s\n", os.Args[0])
        flag.PrintDefaults()
        return
    }

    t0 := time.Now()
    nBytes := uint64(0)
    nIterations := uint64(0)

    encoderDecoder := getEncoder(*encodingType)
    startingLoop := newBigFloat(*nFrom)

    var endLoop *big.Float
    var incrementer *big.Float

    if *nIncrements > 0 {
        // using from/iterations flags
        fmt.Printf("encoding: %v from: %v iterations: %v\n", *encodingType, *nFrom, *nIncrements)

        incrementer = newBigFloat(1)
        n := newBigFloat(*nIncrements)
        endLoop = n.Add(n, startingLoop)
    } else {
        // using from/to/by flags
        fmt.Printf("encoding: %v from: %v to: %v by: %v\n", *encodingType, *nFrom, *nTo, *nBy)
        incrementer = newBigFloat(*nBy)
        endLoop = newBigFloat(*nTo)
    }

    for i := startingLoop; i.Cmp(endLoop) < 0; i = i.Add(i, incrementer) {
        nIterations++
        nBytes += runTest(encoderDecoder, i)
    }

    t1 := time.Now()
    d := t1.Sub(t0)
    fmt.Printf("IO  %s (%v nums) in %s (%s/s)\n", humanize.Bytes(nBytes), humanize.Comma(int64(nIterations)), d, humanize.Bytes(uint64(float64(nBytes)/d.Seconds())))
}

开发者ID:willhite,项目名称:noms-old,代码行数:48,代码来源:main.go

示例5: main

func main() {
    keyname := flag.String("keyname", "hosts", "Etcd keyname under which to record containers' hostnames/IP")
    ttl := flag.Uint64("ttl", 172800, "Time to live of the host entry")
    dockerAPIPort := flag.String("port", "4243", "Docker API Port")
    interval := flag.Duration("interval", 10, "Docker API to Etcd sync interval")
    //etcdHost := flag.String("etcd_host", "127.0.0.1", "Etcd host")
    //etcdPort := flag.String("etcd_port", "4001", "Etcd port")
    concurrency := flag.Int("concurrency", 1, "Number of worker threads")

    flag.Parse()

    //etcdCluster := []string{"http://" + *etcdHost + ":" + *etcdPort}
    etcdClient := etcd.NewClient()
    //etcdClient.SetCluster(etcdCluster)

    dockerClient, err := docker.NewClient("http://127.0.0.1:" + *dockerAPIPort)
    if err != nil {
        log.Fatal(err)
    }

    var c = make(chan string, *concurrency)

    for i := 0; i < *concurrency; i++ {
        go inspectAndSet(c, etcdClient, dockerClient, keyname, ttl)
    }

    loop(c, dockerClient, interval)

}

开发者ID:janstenpickle,项目名称:etcd-dockerhosts,代码行数:29,代码来源:etcd-docker.go

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