Home >Backend Development >Golang >How Do I Correctly Set the Timeout Flag for `go test`?
Using the command go test -timeout 99999, as you've mentioned, generates an error indicating an invalid value. This is because the specified duration lacks a proper unit designation.
The -timeout flag in go test provides an aggregate time limit for all tests. To set it effectively, you must specify a valid time duration using the time.ParseDuration syntax.
For instance, if you wish to set a timeout of 300 milliseconds, use:
$ go test -timeout 300ms
Similarly, to set a timeout of 99999 seconds:
$ go test -timeout 99999s
Refer to the documentation for time.ParseDuration for further details on specifying duration strings.
The above is the detailed content of How Do I Correctly Set the Timeout Flag for `go test`?. For more information, please follow other related articles on the PHP Chinese website!