From bc072f16dd9922085844792b209030e144e16d9c Mon Sep 17 00:00:00 2001 From: David Hontecillas Date: Tue, 3 Sep 2024 09:23:36 +0200 Subject: [PATCH] fix slice var declaration --- config.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/config.go b/config.go index 3a2428a..55418b8 100644 --- a/config.go +++ b/config.go @@ -6,7 +6,7 @@ import ( "encoding/hex" "errors" "io" - "io/ioutil" + "os" "github.com/luraproject/lura/v2/config" "github.com/luraproject/lura/v2/logging" @@ -29,7 +29,7 @@ type SourceLoader interface { Get(string) (string, bool) } -func Parse(l logging.Logger, e config.ExtraConfig, namespace string) (Config, error) { +func Parse(l logging.Logger, e config.ExtraConfig, namespace string) (Config, error) { // skipcq: GO-R1005 res := Config{} v, ok := e[namespace] if !ok { @@ -54,7 +54,7 @@ func Parse(l logging.Logger, e config.ExtraConfig, namespace string) (Config, er sources, ok := c["sources"].([]interface{}) if ok { - s := []string{} + s := make([]string, 0, len(sources)) for _, source := range sources { if t, ok := source.(string); ok { s = append(s, t) @@ -71,7 +71,7 @@ func Parse(l logging.Logger, e config.ExtraConfig, namespace string) (Config, er loader := map[string]string{} for _, source := range res.Sources { - b, err := ioutil.ReadFile(source) + b, err := os.ReadFile(source) if err != nil { l.Error("[Lua] Opening the source file:", err.Error()) continue @@ -120,7 +120,7 @@ func (o onceLoader) Get(k string) (string, bool) { type liveLoader struct{} func (liveLoader) Get(k string) (string, bool) { - b, err := ioutil.ReadFile(k) + b, err := os.ReadFile(k) if err != nil { return "", false }