From 7bd43af427a90038e26fea5ca7987ca082f95432 Mon Sep 17 00:00:00 2001 From: Ville Vesilehto Date: Wed, 28 May 2025 00:44:20 +0300 Subject: [PATCH] fix: loop variable capture and linter (#7328) Enable copyloopvar linter and remove redundant variable shadowing in Kubernetes plugin metadata handling. This pattern is no longer needed in Go 1.22+ where loop variables are automatically captured correctly in closures. Signed-off-by: Ville Vesilehto --- .golangci.yml | 3 ++- plugin/kubernetes/metadata.go | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 3eca2593b..19d1ab4f3 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -2,13 +2,14 @@ version: "2" linters: default: none enable: + - copyloopvar - govet - ineffassign - staticcheck - unconvert - unused - - whitespace - usetesting + - whitespace exclusions: generated: lax presets: diff --git a/plugin/kubernetes/metadata.go b/plugin/kubernetes/metadata.go index 21858f465..c0e369e37 100644 --- a/plugin/kubernetes/metadata.go +++ b/plugin/kubernetes/metadata.go @@ -21,7 +21,6 @@ func (k *Kubernetes) Metadata(ctx context.Context, state request.Request) contex }) for k, v := range pod.Labels { - v := v metadata.SetValueFunc(ctx, "kubernetes/client-label/"+k, func() string { return v })