各种测试参数标志如何在go程序使用中显示

各种测试参数标志如何在go程序使用中显示,go,Go,我有一个小的go命令行实用程序,我正在以通常的方式构建它: go build 我使用标志包添加命令行标志。一切都进行得很顺利,直到我开始看到很多测试标志出现。现在,当我使用flag.usage打印用法时,我看到很多额外的标志: -test.bench string regular expression to select benchmarks to run -test.benchmem print memory allocations for bench

我有一个小的go命令行实用程序,我正在以通常的方式构建它:

go build
我使用
标志
包添加命令行标志。一切都进行得很顺利,直到我开始看到很多测试标志出现。现在,当我使用
flag.usage打印用法时,我看到很多额外的标志:

  -test.bench string
        regular expression to select benchmarks to run
  -test.benchmem
        print memory allocations for benchmarks
  -test.benchtime duration
        approximate run time for each benchmark (default 1s)
  -test.blockprofile string
        write a goroutine blocking profile to the named file after execution
  -test.blockprofilerate int
        if >= 0, calls runtime.SetBlockProfileRate() (default 1)
还有比这更多的东西

我正在使用主标志集并添加带有
flag.IntVar
等的标志


我不知道我做了什么,也不知道这是如何实现的。我的其他程序都没有在默认使用消息中包含这些测试标志。我很感激你的指点

testing
包的
init()
使用flags包向应用程序添加命令行参数


您可能引用了一些非测试代码中的
测试

Hm<代码>grep testing$(ls*.go | grep-v'_test.go')
没有显示任何内容。go如何决定是否在
*\u test.go
文件中编译?啊。你是对的。我在我的包的依赖项中引用了测试,所以我的grep没有接受它。想把它作为答案提交吗?