Home > Backend Development > Golang > Why Does 'go test -timeout 99999' Fail, and How Can I Correctly Set a Timeout for Go Tests?

Why Does 'go test -timeout 99999' Fail, and How Can I Correctly Set a Timeout for Go Tests?

DDD
Release: 2024-12-03 05:14:12
Original
579 people have browsed it

Why Does

Error in Setting Timeout Flag for "Go test" Command

When using go test -timeout 99999, you may encounter the error "invalid value '99999' for flag -test.timeout: time: missing unit in duration 99999". To resolve this issue, it is crucial to provide a valid time.ParseDuration input.

The -timeout flag in the go test command sets an aggregate time limit for all tests. To specify the timeout value, you need to use the correct syntax.

Valid Syntax:

go test -timeout <duration>
Copy after login

Valid Time Units:

  • ns (nanoseconds)
  • us (or µs) (microseconds)
  • ms (milliseconds)
  • s (seconds)
  • m (minutes)
  • h (hours)

Examples of Valid Timeout Values:

  • go test -timeout 300ms
  • go test -timeout 99999s

Additional Notes:

  • The documentation for the -timeout flag indicates that it accepts any input valid for time.ParseDuration. The time.ParseDuration function parses a duration string, such as "300ms", "-1.5h", or "2h45m".
  • The help cli output is not informative in this case as it only provides a brief description of the -timeout flag without specific examples of valid duration values.

The above is the detailed content of Why Does 'go test -timeout 99999' Fail, and How Can I Correctly Set a Timeout for Go Tests?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template