2017-07-29 5 views
0

私はGoでCLIアプリケーションを構築しています。flag.PrintDefaultsに `-test`フラグが含まれています

flag.IntVar(&connections, "c", 1, "Connections to keep open per endpoint") 
flag.IntVar(&duration, "T", 10, "Exit after the specified amount of time in seconds") 
flag.IntVar(&txsRate, "r", 1000, "Txs per second to send in a connection") 
flag.BoolVar(&verbose, "v", false, "Verbose output") 

flag.Usage = func() { 
    fmt.Println(`....`) 
    fmt.Println("Flags:") 
    flag.PrintDefaults() 
} 

flag.Parse() 

if flag.NArg() == 0 { 
    flag.Usage() 
    os.Exit(1) 
} 

Full listing on Github

は、いくつかの奇妙な理由で、上記のスニペットは生成します。

Flags: 


-T int 
     Exit after the specified amount of time in seconds (default 10) 
    -c int 
     Connections to keep open per endpoint (default 1) 
    -r int 
     Txs per second to send in a connection (default 1000) 
    -test.bench regexp 
     run only benchmarks matching regexp 
    -test.benchmem 
     print memory allocations for benchmarks 
    -test.benchtime d 
     run each benchmark for duration d (default 1s) 
    -test.blockprofile file 
     write a goroutine blocking profile to file 
    -test.blockprofilerate rate 
     set blocking profile rate (see runtime.SetBlockProfileRate) (default 1) 
    -test.count n 
     run tests and benchmarks n times (default 1) 
    -test.coverprofile file 
     write a coverage profile to file 
    -test.cpu list 
     comma-separated list of cpu counts to run each test with 
    -test.cpuprofile file 
     write a cpu profile to file 
    -test.memprofile file 
     write a memory profile to file 
    -test.memprofilerate rate 
     set memory profiling rate (see runtime.MemProfileRate) 
    -test.mutexprofile string 
     write a mutex contention profile to the named file after execution 
    -test.mutexprofilefraction int 
     if >= 0, calls runtime.SetMutexProfileFraction() (default 1) 
    -test.outputdir dir 
     write profiles to dir 
    -test.parallel n 
     run at most n tests in parallel (default 2) 
    -test.run regexp 
     run only tests and examples matching regexp 
    -test.short 
     run smaller test suite to save time 
    -test.timeout d 
     fail test binary execution after duration d (0 means unlimited) 
    -test.trace file 
     write an execution trace to file 
    -test.v 
     verbose: print additional output 
    -v Verbose output 

Goは-testフラグが含まれてなぜ任意のアイデア?ありがとう!

+1

"テスト"パッケージをインポートしています。 – JimB

+0

https://github.com/tendermint/tools/blob/develop/tm-bench/main.goそうは考えていませんが、確かにテストパッケージのように見えます – melekes

+0

正確なコマンドは何ですかあなたはあなたのバイナリをビルドしますか? –

答えて

0

私はあなたのコードに束f依存があることがわかります。私はライブラリgithub.com/tendermint/tmlibs/logが標準ライブラリのtestingパッケージに依存していることを発見しました:searches for testing。この標準ライブラリには、あなたが不思議に思うすべてのフラグがあります:testing package

+0

ああ、いいえ!あなたが正しい。ありがとう – melekes

関連する問題