go test -timeout 99999
抛出这个无意义的错误
invalid value "99999" for flag -test.timeout:
time: missing unit in duration 99999
这是一个错误吗? 我在用着 去版本go1.3
“帮助”cli 也无用。它说 -test.timeout=0: 如果是肯定的,则为所有测试设置一个聚合时间限制
。但是如果你去 test -test.timeout 99999 你会得到同样的错误
-test.timeout=0: if positive, sets an aggregate time limit for all tests
最佳答案
使用有效的 time.ParseDuration
输入。例如,
$ go test -timeout 300ms
$ go test -timeout 99999s
-timeout t
If a test runs longer than
t
,panic
.Duration flags accept any input valid for
time.ParseDuration
.func ParseDuration(s string) (Duration, error)
ParseDuration parses a duration string. A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "
300ms
", "-1.5h
" or "2h45m
". Valid time units are "ns
", "us
" (or "µs
"), "ms
", "s
", "m
", "h
".
关于testing - 如何在 "Go test"上设置 go timeout 标志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24929790/