From 5478cd77a5360c07795cf93300f016c0a2a9231e Mon Sep 17 00:00:00 2001 From: Matt Benson Date: Wed, 31 Jan 2024 11:45:08 -0600 Subject: [PATCH] migrate from deprecated ioutil dependency --- load.go | 6 +++--- load_test.go | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/load.go b/load.go index 635368d..b2ef6c7 100644 --- a/load.go +++ b/load.go @@ -6,7 +6,7 @@ package properties import ( "fmt" - "io/ioutil" + "io" "net/http" "os" "strings" @@ -91,7 +91,7 @@ func (l *Loader) LoadAll(names []string) (*Properties, error) { // If IgnoreMissing is true then a missing file will not be // reported as error. func (l *Loader) LoadFile(filename string) (*Properties, error) { - data, err := ioutil.ReadFile(filename) + data, err := os.ReadFile(filename) if err != nil { if l.IgnoreMissing && os.IsNotExist(err) { LogPrintf("properties: %s not found. skipping", filename) @@ -126,7 +126,7 @@ func (l *Loader) LoadURL(url string) (*Properties, error) { return nil, fmt.Errorf("properties: %s returned %d", url, resp.StatusCode) } - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return nil, fmt.Errorf("properties: %s error reading response. %s", url, err) } diff --git a/load_test.go b/load_test.go index f863838..6863425 100644 --- a/load_test.go +++ b/load_test.go @@ -6,7 +6,6 @@ package properties import ( "fmt" - "io/ioutil" "net/http" "net/http/httptest" "os" @@ -183,9 +182,9 @@ func (tf *tempFiles) makeFile(data string) string { } func (tf *tempFiles) makeFilePrefix(prefix, data string) string { - f, err := ioutil.TempFile("", prefix) + f, err := os.CreateTemp("", prefix) if err != nil { - panic("ioutil.TempFile: " + err.Error()) + panic("os.TempFile: " + err.Error()) } // remember the temp file so that we can remove it later