How can I compile tests to Binary and run Single Test

Hi,I am work on a toy fuzzer and want to compile the tests to a binary and run a single test each time.
I am at go1.17 and I already know that one can use

go test -c /path/to/src -o output_name

to get a binary, but when i run this

.\pkg.test.exe TestDemo

or any other -test options (eg -test.list), it will fail and output this:

flag provided but not defined: -test
Usage of pkg.test:
  -test.bench regexp
        run only benchmarks matching regexp

Anyone can help? I would appreciate.

Solved, it is the problem of my env.

1 Like