diff --git a/internal/common/common_linux.go b/internal/common/common_linux.go index 9c9088d14..b58edbeb0 100644 --- a/internal/common/common_linux.go +++ b/internal/common/common_linux.go @@ -30,7 +30,6 @@ func DoSysctrl(mib string) ([]string, error) { return values, nil } -// Deprecated: use NumProcsWithContext instead func NumProcs() (uint64, error) { return NumProcsWithContext(context.Background()) } diff --git a/internal/common/common_test.go b/internal/common/common_test.go index 43638bf49..424ea26ab 100644 --- a/internal/common/common_test.go +++ b/internal/common/common_test.go @@ -178,11 +178,7 @@ func TestGetEnvWithNoContext(t *testing.T) { if runtime.GOOS == "windows" { t.Skip("windows doesn't have etc") } - old := os.Getenv("HOST_ETC") - os.Setenv("HOST_ETC", "/bar") - defer func() { - os.Setenv("HOST_ETC", old) - }() + t.Setenv("HOST_ETC", "/bar") p := HostEtcWithContext(context.Background(), "mtab") if p != "/bar/mtab" { t.Errorf("invalid HostEtc, %s", p) @@ -193,11 +189,7 @@ func TestGetEnvWithContextOverride(t *testing.T) { if runtime.GOOS == "windows" { t.Skip("windows doesn't have etc") } - old := os.Getenv("HOST_ETC") - os.Setenv("HOST_ETC", "/bar") - defer func() { - os.Setenv("HOST_ETC", old) - }() + t.Setenv("HOST_ETC", "/bar") ctx := context.WithValue(context.Background(), common.EnvKey, common.EnvMap{common.HostEtcEnvKey: "/foo"}) p := HostEtcWithContext(ctx, "mtab") if p != "/foo/mtab" {