测试“ -timeout 0”未反映在执行中

I am using Go 1.9.2 version and invoking the test with timeout disabled using -timeout 0 flag.

go test my_module -run TestModule -v --race -timeout 0

But the test execution is getting timed out after default timeout of 10m.

*** Test killed: ran too long (10m0s).

Its the way the testing library is handling that flag value:

https://github.com/golang/go/blob/adcecbe05ef812bc8ff477dec47720a2cfc273e3/src/testing/testing.go#L1299

It only uses the given value if the timeout is greater than 0. Therefore, by setting it to 0, it just uses the default (10m).

It's test.timeout i.e.

go test my_module -run TestModule -v --race -test.timeout 0