Skip to content

Commit 27e2bdb

Browse files
committed
fix: avoid variable shadowing by renaming local 'errors' variable
The local variable 'errors' was shadowing the standard library 'errors' package, which can lead to confusion and potential issues when calling package functions. Renamed the variable to 'errs' to clarify intent and resolve the name collision.
1 parent 06c0575 commit 27e2bdb

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

pkg/model/resource/gvk.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,17 @@ func (gvk GVK) Validate() error {
5656
if gvk.Version == "" {
5757
return errors.New(versionRequired)
5858
}
59-
errs := validation.IsDNS1123Subdomain(gvk.Version)
60-
if len(errs) > 0 && gvk.Version != versionInternal {
59+
if errs := validation.IsDNS1123Subdomain(gvk.Version); len(errs) > 0 && gvk.Version != versionInternal {
6160
return fmt.Errorf("Version must respect DNS-1123 (was %s)", gvk.Version)
6261
}
6362

6463
// Check if kind has a valid DNS1035 label value
6564
if gvk.Kind == "" {
6665
return errors.New(kindRequired)
6766
}
68-
if errors := validation.IsDNS1035Label(strings.ToLower(gvk.Kind)); len(errors) != 0 {
67+
if errs := validation.IsDNS1035Label(strings.ToLower(gvk.Kind)); len(errs) != 0 {
6968
// NOTE: IsDNS1035Label returns a slice of strings instead of an error, so no wrapping
70-
return fmt.Errorf("invalid Kind: %#v", errors)
69+
return fmt.Errorf("invalid Kind: %#v", errs)
7170
}
7271

7372
// Require kind to start with an uppercase character

0 commit comments

Comments
 (0)