From 4052d269f51d12477ca980d1d3cb389a727d80b4 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 9 May 2023 15:29:12 +0200 Subject: [PATCH] reference, registry: fix loop variable captured by func literal (govet) reference/normalize_test.go:274:40: loopclosure: loop variable r captured by func literal (govet) named, err := ParseNormalizedNamed(r) ^ reference/normalize_test.go:276:29: loopclosure: loop variable r captured by func literal (govet) t.Fatalf("ref=%s: %v", r, err) ^ registry/api/errcode/errors_test.go:45:7: loopclosure: loop variable ec captured by func literal (govet) if ec != desc.Code { ^ registry/api/errcode/errors_test.go:46:66: loopclosure: loop variable ec captured by func literal (govet) t.Fatalf("error code in descriptor isn't correct, %q != %q", ec, desc.Code) ^ registry/api/errcode/errors_test.go:49:23: loopclosure: loop variable desc captured by func literal (govet) if idToDescriptors[desc.Value].Code != ec { ^ registry/api/errcode/errors_test.go:50:80: loopclosure: loop variable desc captured by func literal (govet) t.Fatalf("error code in idToDesc isn't correct, %q != %q", idToDescriptors[desc.Value].Code, ec) ^ registry/api/errcode/errors_test.go:53:7: loopclosure: loop variable ec captured by func literal (govet) if ec.Message() != desc.Message { ^ Signed-off-by: Sebastiaan van Stijn --- reference/normalize_test.go | 1 + registry/api/errcode/errors_test.go | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/reference/normalize_test.go b/reference/normalize_test.go index 0932d06f..f1b6f27a 100644 --- a/reference/normalize_test.go +++ b/reference/normalize_test.go @@ -269,6 +269,7 @@ func TestParseRepositoryInfo(t *testing.T) { } for _, r := range refStrings { + r := r t.Run(strconv.Itoa(i)+"/"+r, func(t *testing.T) { t.Parallel() named, err := ParseNormalizedNamed(r) diff --git a/registry/api/errcode/errors_test.go b/registry/api/errcode/errors_test.go index 6a7eb7d2..105d9f7c 100644 --- a/registry/api/errcode/errors_test.go +++ b/registry/api/errcode/errors_test.go @@ -39,9 +39,11 @@ func TestErrorCodes(t *testing.T) { t.Fatal("errors aren't loaded!") } - for ec, desc := range errorCodeToDescriptors { + for ec := range errorCodeToDescriptors { + ec := ec t.Run(ec.String(), func(t *testing.T) { t.Parallel() + desc := errorCodeToDescriptors[ec] if ec != desc.Code { t.Fatalf("error code in descriptor isn't correct, %q != %q", ec, desc.Code) }