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())?
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())?