dst2017 2016-05-15 15:23
浏览 25
已采纳

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

I have a small go command line utility that I am building in the usual way:

go build

I use the flag package to add command line flags. And all was going swimmingly until I started getting a lot of test flags showing up. Now when I print the usage using flag.Usage I see lots of extra flags:

  -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)

There are a lot more than this.

I am using the main flag set and adding flags with flag.IntVar and the like.

I can't figure out what I did or how this could have been enabled. None of my other programs include these test flags in the default usage message. I appreciate any pointers.

  • 写回答

1条回答 默认 最新

  • duanchi1230 2016-05-16 15:34
    关注

    The testing package's init() adds command line arguments to your app using the flags package.

    You are likely referencing testing from some bit of non-testing code.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog