Flag uses of os.{Setenv,Chdir}() in tests
Author: arp242Created Mar 12, 2026Updated Mar 14, 2026
Labelsnew-check
Test functions should use testing.T.{Setenv,Chdir} instead; these helpers will correctly restore the previous value with t.Cleanup() and prevent t.Parallel()
I can't really think of any scenario where you would call the os versions in a test?
Possibly also os.TempDir() and os.{CreateTemp,MkdirTemp}() (when called with the default directory or os.TempDir())?
Source: dominikh/go-tools