本文介绍了如何在“Go测试”上设置超时超时标志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  go test -timeout 99999 

抛出这种无意义错误

 标志-test.timeout的无效值99999:
时间:持续时间内缺少单位99999

这是一个错误吗?
我使用
go版本go1.3



helpcli也没用。它表示 -test.timeout = 0:如果为正数,则为所有测试设置一个总计时间限制。但是,如果你去测试-test.timeout 99999你会得到同样的错误

  -test.timeout = 0:为所有测试设置一个合计时间限制


解决方案

time.ParseDuration 输入。例如,

  $ go test -timeout 300ms 

$ go test -timeout 99999s




go test -timeout 99999

throws this non sense error

invalid value "99999" for flag -test.timeout:
time: missing unit in duration 99999

Is it a bug ?I'm using go version go1.3

The "help" cli is useless too. It says -test.timeout=0: if positive, sets an aggregate time limit for all tests. However if you do go test -test.timeout 99999 you get the same error

 -test.timeout=0: if positive, sets an aggregate time limit for all tests
解决方案

Use a valid time.ParseDuration input. For example,

$ go test -timeout 300ms

$ go test -timeout 99999s

这篇关于如何在“Go测试”上设置超时超时标志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 05:15