1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
package bolttest import ( "os" "testing" "git.sr.ht/~eugenetriguba/checkmate/assert" ) func UnsetEnv(t *testing.T, key string) { originalVal, isSet := os.LookupEnv(key) if isSet { t.Cleanup(func() { err := os.Setenv(key, originalVal) assert.Nil(t, err) }) os.Unsetenv(key) } }