From d39d2cffcc6c6a9325e1456098dbe363c2ad7d0b Mon Sep 17 00:00:00 2001 From: Rakshith R Date: Fri, 5 Aug 2022 16:31:31 +0530 Subject: [PATCH] cleanup: use index instead of value while iterating This commit cleans up for loop to use index to access value instead of copying value into a new variable while iterating. ``` internal/util/csiconfig.go:103:2: rangeValCopy: each \ iteration copies 136 bytes (consider pointers or indexing) \ (gocritic) for _, cluster := range config { ``` Signed-off-by: Rakshith R --- internal/util/csiconfig.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/util/csiconfig.go b/internal/util/csiconfig.go index 96c8915df..c6ec96305 100644 --- a/internal/util/csiconfig.go +++ b/internal/util/csiconfig.go @@ -100,9 +100,9 @@ func readClusterInfo(pathToConfig, clusterID string) (*ClusterInfo, error) { err, string(content)) } - for _, cluster := range config { - if cluster.ClusterID == clusterID { - return &cluster, nil + for i := range config { + if config[i].ClusterID == clusterID { + return &config[i], nil } }