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 R语言卸载之后无法重装,显示电脑存在下载某些较大二进制文件行为,怎么办
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?
  • ¥15 关于#vue.js#的问题:修改用户信息功能图片无法回显,数据库中只存了一张图片(相关搜索:字符串)
  • ¥15 texstudio的问题,
  • ¥15 spaceclaim模型变灰色
  • ¥15 求一份华为esight平台V300R009C00SPC200这个型号的api接口文档
  • ¥15 字符串比较代码的漏洞
  • ¥15 欧拉系统opt目录空间使用100%
  • ¥15 ul做导航栏格式不对怎么改?