My requirement is that I need to initialize pretty expensive data structures for benchmarking, that I do not need for normal tests. I would like to avoid initializing them as this would speed up my tests a lot.
On Tue, Sep 22, 2015, 19:29 <pierre...@gmail.com> wrote:
Declare test flags in your foo_test.go at pkg level:
var x = flag.Bool(...)
Do not call flag.Parse in the test file. No need for TestMain either.
-j
Hmm. Thanks for the answers but I knew this, and this is not what I am after :).If I run the following command:go test -bench ExtI want to know within my _test.go file if I have the -bench flag and the value passed with it, i.e. the arguments to "go test", not to my program.Basically I want to know if I need to initialize my data structures for benchmarks. I have a couple of them so I would like to run them in separate goroutines and only if I need them.