Proposal Details
Add a new analyzer that replaces manual environment variable save/restore with t.Setenv (Go 1.17+).
// Before
defer os.Setenv("GOOS", os.Getenv("GOOS"))
os.Setenv("GOOS", f[0])
// After
t.Setenv("GOOS", f[0])
Conditions
- Pattern: defer os.Setenv(key, os.Getenv(key)) followed by os.Setenv(key, value)
- defer must precede os.Setenv (defer args are evaluated immediately)
- Within test function, before any t.Parallel() call
- Go 1.17+
Similar to testingcontext analyzer.
Proposal Details
Add a new analyzer that replaces manual environment variable save/restore with t.Setenv (Go 1.17+).
Conditions
Similar to testingcontext analyzer.