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

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

示例1: init

func init() {
    flag.Usage = usage

    flag.BoolVar(&Settings.verbose, "verbose", false, "Turn on verbose/debug output")
    flag.BoolVar(&Settings.stats, "stats", false, "Turn on queue stats output")

    flag.BoolVar(&Settings.splitOutput, "split-output", false, "By default each output gets same traffic. If set to `true` it splits traffic equally among all outputs.")

    flag.Var(&Settings.inputDummy, "input-dummy", "Used for testing outputs. Emits 'Get /' request every 1s")
    flag.Var(&Settings.outputDummy, "output-dummy", "Used for testing inputs. Just prints data coming from inputs.")

    flag.Var(&Settings.inputTCP, "input-tcp", "Used for internal communication between Gor instances. Example: \n\t# Receive requests from other Gor instances on 28020 port, and redirect output to staging\n\tgor --input-tcp :28020 --output-http staging.com")
    flag.Var(&Settings.outputTCP, "output-tcp", "Used for internal communication between Gor instances. Example: \n\t# Listen for requests on 80 port and forward them to other Gor instance on 28020 port\n\tgor --input-raw :80 --output-tcp replay.local:28020")
    flag.BoolVar(&Settings.outputTCPStats, "output-tcp-stats", false, "Report TCP output queue stats to console every 5 seconds.")

    flag.Var(&Settings.inputFile, "input-file", "Read requests from file: \n\tgor --input-file ./requests.gor --output-http staging.com")
    flag.Var(&Settings.outputFile, "output-file", "Write incoming requests to file: \n\tgor --input-raw :80 --output-file ./requests.gor")

    flag.Var(&Settings.inputRAW, "input-raw", "Capture traffic from given port (use RAW sockets and require *sudo* access):\n\t# Capture traffic from 8080 port\n\tgor --input-raw :8080 --output-http staging.com")

    flag.Var(&Settings.inputHTTP, "input-http", "Read requests from HTTP, should be explicitly sent from your application:\n\t# Listen for http on 9000\n\tgor --input-http :9000 --output-http staging.com")

    flag.Var(&Settings.outputHTTP, "output-http", "Forwards incoming requests to given http address.\n\t# Redirect all incoming requests to staging.com address \n\tgor --input-raw :80 --output-http http://staging.com")
    flag.IntVar(&Settings.outputHTTPConfig.workers, "output-http-workers", 0, "Gor uses dynamic worker scaling by default.  Enter a number to run a set number of workers.")
    flag.IntVar(&Settings.outputHTTPConfig.redirectLimit, "output-http-redirects", 0, "Enable how often redirects should be followed.")
    flag.Var(&Settings.modifierConfig.headers, "output-http-header", "Inject additional headers to http reqest:\n\tgor --input-raw :8080 --output-http staging.com --output-http-header 'User-Agent: Gor'")
    flag.Var(&Settings.modifierConfig.methods, "output-http-method", "Whitelist of HTTP methods to replay. Anything else will be dropped:\n\tgor --input-raw :8080 --output-http staging.com --output-http-method GET --output-http-method OPTIONS")
    flag.Var(&Settings.modifierConfig.urlRegexp, "output-http-url-regexp", "A regexp to match requests against. Anything else will be dropped:\n\t gor --input-raw :8080 --output-http staging.com --output-http-url-regexp ^www.")
    flag.Var(&Settings.modifierConfig.urlRewrite, "output-http-rewrite-url", "Rewrite the requst url based on a mapping:\n\tgor --input-raw :8080 --output-http staging.com --output-http-rewrite-url /xml_test/interface.php:/api/service.do")
    flag.Var(&Settings.modifierConfig.headerFilters, "output-http-header-filter", "A regexp to match a specific header against. Requests with non-matching headers will be dropped:\n\t gor --input-raw :8080 --output-http staging.com --output-http-header-filter api-version:^v1")
    flag.Var(&Settings.modifierConfig.headerHashFilters, "output-http-header-hash-filter", "Takes a fraction of requests, consistently taking or rejecting a request based on the FNV32-1A hash of a specific header. The fraction must have a denominator that is a power of two:\n\t gor --input-raw :8080 --output-http staging.com --output-http-header-hash-filter user-id:1/4")
    flag.BoolVar(&Settings.outputHTTPConfig.stats, "output-http-stats", false, "Report http output queue stats to console every 5 seconds.")

    flag.StringVar(&Settings.outputHTTPConfig.elasticSearch, "output-http-elasticsearch", "", "Send request and response stats to ElasticSearch:\n\tgor --input-raw :8080 --output-http staging.com --output-http-elasticsearch 'es_host:api_port/index_name'")
}

开发者ID:morsharon,项目名称:gor,代码行数:35,代码来源:settings.go

示例2: main

func main() {

    flag.IntVar(&pc, "pc", 3, "player count (3-5)")
    flag.IntVar(&lp, "lp", 50, "target loss percent (1-99, default 50")
    flag.IntVar(&rg, "rg", 10, "allowable difficulty variance around target loss percent (0-100, default 10")

    var err error

    if err = validateFlags(); err != nil {
        fmt.Println(err)
        return
    }

    s, i, err := sentinels.FindSetup(pc, lp, rg, []sentinels.ExpansionType{sentinels.BaseSet, sentinels.MiniExpansion})
    if err != nil {
        fmt.Println(err)
        return
    }
    if s != nil {
        fmt.Printf("\nFound in %d iterations:\n\n", i)
        fmt.Printf("%s", s)
    } else {
        fmt.Printf("\nNo setup found in %d iterations.\n", i)
    }

}

开发者ID:uhhhclem,项目名称:sentinels,代码行数:26,代码来源:app.go

示例3: init

func init() {
    flag.IntVar(&size, "s", 40, "bubble size")
    flag.IntVar(&niter, "n", 200, "number of iterations")
    flag.Float64Var(&opacity, "o", 0.5, "opacity")
    flag.Parse()
    rand.Seed(int64(time.Now().Nanosecond()) % 1e9)
}

开发者ID:rif,项目名称:golang-stuff,代码行数:7,代码来源:bubtrail.go

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

开发者ID:cheetah0216,项目名称:kafka-pusher,代码行数:7,代码来源:main.go

示例5: main

func main() {
    hostname, err := os.Hostname()
    if err != nil {
        hostname = "unknown"
    }

    flag.StringVar(&prefix, "p", fmt.Sprintf("bucky-pickle-relay.%s", hostname),
        "Prefix for internally generated metrics.")
    flag.StringVar(&bindTo, "b", ":2004",
        "Address to bind to for incoming connections.")
    flag.BoolVar(&debug, "d", false,
        "Debug mode.")
    flag.IntVar(&pickleTimeout, "t", 300,
        "Timeout in seconds on incoming pickle protocol TCP connections.")
    flag.IntVar(&sendTimeout, "s", 30,
        "TCP timeout in seconds for outgoing line protocol connections.")
    flag.IntVar(&maxPickleSize, "x", 1*1024*1024,
        "Maximum pickle size accepted.")
    flag.IntVar(&pickleQueueSize, "q", 0,
        "Internal buffer sizes.")
    flag.DurationVar(&metricInterval, "i", 60,
        "Interval in seconds between reporting of internal metrics.")
    flag.Parse()
    if flag.NArg() != 1 {
        usage()
    }

    log.Printf("bucky-pickle-relay Copyright 2015 42 Lines, Inc.")
    carbonRelay = flag.Arg(0)
    log.Printf("Sending line protocol data to %s", carbonRelay)
    log.Printf("Reporting internal metrics under %s", prefix)

    metrics := serveForever()
    plainTextOut(metrics)
}

开发者ID:olivierHa,项目名称:buckytools,代码行数:35,代码来源:main.go

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