我有一個小型的 go 命令行實用程序,我正在以通常的方式構(gòu)建它:go build我使用flag包來添加命令行標(biāo)志。一切都很順利,直到我開始出現(xiàn)很多測試標(biāo)志?,F(xiàn)在,當(dāng)我使用打印用法時,flag.Usage我看到了很多額外的標(biāo)志: -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)不止于此。我正在使用主標(biāo)志集并添加標(biāo)志flag.IntVar等。我無法弄清楚我做了什么或如何啟用它。我的其他程序都沒有在默認(rèn)使用消息中包含這些測試標(biāo)志。我很感激任何指示。
一些如何在 go 程序使用中顯示各種測試參數(shù)標(biāo)志
慕的地6264312
2022-01-10 16:35:10