8000 Flag uses of os.{Setenv,Chdir}() in tests · Issue #1707 · dominikh/go-tools · GitHub
[go: up one dir, main page]

Skip to content

Flag uses of os.{Setenv,Chdir}() in tests #1707

Open

Description

@arp242

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

Activity

  1. added and removed
    needs-triageNewly filed issue that needs triage
    on Mar 12, 2026
  2. ccoVeille commented on Mar 14, 2026

    @ccoVeille

    For record: @ldez usetesting already reports it 🥰 (and way more)

    It's available in golangci-lint via configuration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0