From ca92e8c39b96fd915ce80142c053d80aa3c7a234 Mon Sep 17 00:00:00 2001 From: Plamerdi Makela Date: Thu, 13 Nov 2025 15:56:48 +0100 Subject: [PATCH] all: remove unnecessary loop variables Since 1.22, this is no longer needed. As of now, go.mod supports 1.23 and onwards. Link: https://go.dev/doc/go1.22#vet-loopclosure Signed-off-by: Plamerdi Makela --- devices/devices_emulator_test.go | 2 -- fs2/create.go | 1 - systemd/freeze_test.go | 1 - systemd/systemd_test.go | 1 - utils_test.go | 2 -- 5 files changed, 7 deletions(-) diff --git a/devices/devices_emulator_test.go b/devices/devices_emulator_test.go index 24c1d1e..3db9416 100644 --- a/devices/devices_emulator_test.go +++ b/devices/devices_emulator_test.go @@ -741,7 +741,6 @@ func testDeviceEmulatorApply(t *testing.T, baseDefaultAllow bool) { } for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { err := test.base.Apply(test.rule) if err != nil && test.expected != nil { @@ -1058,7 +1057,6 @@ func testDeviceEmulatorTransition(t *testing.T, sourceDefaultAllow bool) { } for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { // If we are in black-list mode, we need to prepend the relevant // clear-all rule (the expected rule lists are written with diff --git a/fs2/create.go b/fs2/create.go index 565ca88..a1f1dd6 100644 --- a/fs2/create.go +++ b/fs2/create.go @@ -97,7 +97,6 @@ func CreateCgroupPath(path string, c *cgroups.Cgroup) (Err error) { } } else { // If the directory was created, be sure it is not left around on errors. - current := current defer func() { if Err != nil { os.Remove(current) diff --git a/systemd/freeze_test.go b/systemd/freeze_test.go index 35558a8..0f05137 100644 --- a/systemd/freeze_test.go +++ b/systemd/freeze_test.go @@ -131,7 +131,6 @@ func TestFreezeBeforeSet(t *testing.T) { } for _, tc := range testCases { - tc := tc t.Run(tc.desc, func(t *testing.T) { m, err := NewLegacyManager(tc.cg, nil) if err != nil { diff --git a/systemd/systemd_test.go b/systemd/systemd_test.go index 60a6c1f..156e55e 100644 --- a/systemd/systemd_test.go +++ b/systemd/systemd_test.go @@ -160,7 +160,6 @@ func TestUnifiedResToSystemdProps(t *testing.T) { } for _, tc := range testCases { - tc := tc t.Run(tc.name, func(t *testing.T) { if tc.minVer != 0 && systemdVersion(cm) < tc.minVer { t.Skipf("requires systemd >= %d", tc.minVer) diff --git a/utils_test.go b/utils_test.go index 79023b7..d712fc6 100644 --- a/utils_test.go +++ b/utils_test.go @@ -512,7 +512,6 @@ func TestGetHugePageSizeImpl(t *testing.T) { } for _, c := range testCases { - c := c t.Run(c.doc, func(t *testing.T) { output, err := getHugePageSizeFromFilenames(c.input) t.Log("input:", c.input, "; output:", output, "; err:", err) @@ -639,7 +638,6 @@ func TestConvertMemorySwapToCgroupV2Value(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.descr, func(t *testing.T) { swap, err := ConvertMemorySwapToCgroupV2Value(c.memswap, c.memory) if c.expErr {