From ef0fdfa63dd1e6d535804f189fc0761baba3bd47 Mon Sep 17 00:00:00 2001 From: Nic Cope Date: Wed, 29 May 2024 15:35:37 -0700 Subject: [PATCH] Fix linter issues surfaced by new linter config Signed-off-by: Nic Cope --- pkg/fieldpath/merge.go | 2 +- pkg/password/password.go | 2 +- pkg/reference/reference.go | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/fieldpath/merge.go b/pkg/fieldpath/merge.go index 2e23777..dab88d4 100644 --- a/pkg/fieldpath/merge.go +++ b/pkg/fieldpath/merge.go @@ -93,7 +93,7 @@ func removeSourceDuplicates(dst, src any) any { } result := reflect.New(sliceSrc.Type()).Elem() // we will not modify src - for i := 0; i < sliceSrc.Len(); i++ { + for i := range sliceSrc.Len() { itemSrc := sliceSrc.Index(i) found := false for j := 0; j < sliceDst.Len() && !found; j++ { diff --git a/pkg/password/password.go b/pkg/password/password.go index 1e74501..bdf31a2 100644 --- a/pkg/password/password.go +++ b/pkg/password/password.go @@ -48,7 +48,7 @@ func Generate() (string, error) { // Generate a password. func (s Settings) Generate() (string, error) { pw := make([]byte, s.Length) - for i := 0; i < s.Length; i++ { + for i := range s.Length { n, err := rand.Int(rand.Reader, big.NewInt(int64(len(s.CharacterSet)))) if err != nil { return "", err diff --git a/pkg/reference/reference.go b/pkg/reference/reference.go index 56213b3..3248e21 100644 --- a/pkg/reference/reference.go +++ b/pkg/reference/reference.go @@ -107,7 +107,7 @@ func ToIntPtrValue(v string) *int64 { // string pointers and need to be resolved as part of `ResolveMultiple`. func FromPtrValues(v []*string) []string { res := make([]string, len(v)) - for i := 0; i < len(v); i++ { + for i := range len(v) { res[i] = FromPtrValue(v[i]) } return res @@ -116,7 +116,7 @@ func FromPtrValues(v []*string) []string { // FromFloatPtrValues adapts a slice of float64 pointer fields for use as CurrentValues. func FromFloatPtrValues(v []*float64) []string { res := make([]string, len(v)) - for i := 0; i < len(v); i++ { + for i := range len(v) { res[i] = FromFloatPtrValue(v[i]) } return res @@ -125,7 +125,7 @@ func FromFloatPtrValues(v []*float64) []string { // FromIntPtrValues adapts a slice of int64 pointer fields for use as CurrentValues. func FromIntPtrValues(v []*int64) []string { res := make([]string, len(v)) - for i := 0; i < len(v); i++ { + for i := range len(v) { res[i] = FromIntPtrValue(v[i]) } return res @@ -138,7 +138,7 @@ func FromIntPtrValues(v []*int64) []string { // string pointers and need to be resolved as part of `ResolveMultiple`. func ToPtrValues(v []string) []*string { res := make([]*string, len(v)) - for i := 0; i < len(v); i++ { + for i := range len(v) { res[i] = ToPtrValue(v[i]) } return res @@ -147,7 +147,7 @@ func ToPtrValues(v []string) []*string { // ToFloatPtrValues adapts ResolvedValues for use as a slice of float64 pointer fields. func ToFloatPtrValues(v []string) []*float64 { res := make([]*float64, len(v)) - for i := 0; i < len(v); i++ { + for i := range len(v) { res[i] = ToFloatPtrValue(v[i]) } return res @@ -156,7 +156,7 @@ func ToFloatPtrValues(v []string) []*float64 { // ToIntPtrValues adapts ResolvedValues for use as a slice of int64 pointer fields. func ToIntPtrValues(v []string) []*int64 { res := make([]*int64, len(v)) - for i := 0; i < len(v); i++ { + for i := range len(v) { res[i] = ToIntPtrValue(v[i]) } return res