From 170d23713ace4f2d9554500c713ecf9783fde60f Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Mon, 6 Oct 2025 21:05:05 +0300 Subject: [PATCH] refactor: Simplify for range loops --- .golangci.yml | 1 + github/github_test.go | 2 +- github/strings.go | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index f35bafec21e..fb4b385019d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -15,6 +15,7 @@ linters: - godot - goheader - gosec + - intrange - misspell - nakedret - paralleltest diff --git a/github/github_test.go b/github/github_test.go index 71479fb78c1..ec9af05a5dd 100644 --- a/github/github_test.go +++ b/github/github_test.go @@ -193,7 +193,7 @@ func testAddURLOptions(t *testing.T, url string, v any, want string) { t.Helper() vt := reflect.Indirect(reflect.ValueOf(v)).Type() - for i := 0; i < vt.NumField(); i++ { + for i := range vt.NumField() { field := vt.Field(i) if alias, ok := field.Tag.Lookup("url"); ok { if alias == "" { diff --git a/github/strings.go b/github/strings.go index d7a52e283be..da19a54ed90 100644 --- a/github/strings.go +++ b/github/strings.go @@ -38,7 +38,7 @@ func stringifyValue(w *bytes.Buffer, val reflect.Value) { fmt.Fprintf(w, `"%v"`, v) case reflect.Slice: w.WriteByte('[') - for i := 0; i < v.Len(); i++ { + for i := range v.Len() { if i > 0 { w.WriteByte(' ') } @@ -62,7 +62,7 @@ func stringifyValue(w *bytes.Buffer, val reflect.Value) { w.WriteByte('{') var sep bool - for i := 0; i < v.NumField(); i++ { + for i := range v.NumField() { fv := v.Field(i) if fv.Kind() == reflect.Pointer && fv.IsNil() { continue