Skip to content

Go 1.26: Test modernization — T.Chdir() adoption #7095

@spboyer

Description

@spboyer

Parent Issue

Part of #7081 — Go 1.26 Modernization

Description

Adopt T.Chdir() (Go 1.24) in tests that manually change working directories.

Pattern

// Before
oldDir, _ := os.Getwd()
os.Chdir(tempDir)
defer os.Chdir(oldDir)

// After
t.Chdir(tempDir) // auto-restored when test ends

Benefits

  • Safer — directory always restored even on panic
  • No forgotten defers
  • Cleaner test code

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions