You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A new rule redundant-test-main-os-exit that suggests removing os.Exit.
Describe alternatives you've considered
Search for os.Exit manually and refactor TestMain functions.
Additional context
As of Go 1.15, we do not need to call os.Exit(m.Run()) explicitly, as value returned by m.Run() is stored into unexported field of m and go test executable is smart enough to automatically call os.Exit(retValue) when TestMain returns. See golang/go#34129 and https://pkg.go.dev/testing#hdr-Main
These PRs performs removing os.Exit from TestMain in a wild:
As of Go 1.15, we do not need to call os.Exit(m.Run()) explicitly, as value returned by m.Run() is stored into unexported field of m and go test executable is smart enough to automatically call os.Exit(retValue) when TestMain returns.
Is your feature request related to a problem? Please describe.
Implement a rule that suggests removing
os.Exit
inTestMain
for test files.Before:
After:
Describe the solution you'd like
A new rule
redundant-test-main-os-exit
that suggests removingos.Exit
.Describe alternatives you've considered
Search for
os.Exit
manually and refactorTestMain
functions.Additional context
As of Go 1.15, we do not need to call
os.Exit(m.Run())
explicitly, as value returned bym.Run()
is stored into unexported field ofm
and go test executable is smart enough to automatically callos.Exit(retValue)
whenTestMain
returns. See golang/go#34129 and https://pkg.go.dev/testing#hdr-MainThese PRs performs removing
os.Exit
fromTestMain
in a wild:The text was updated successfully, but these errors were encountered: