Skip to content

Commit

Permalink
Merge pull request #73 from mbenson/dep
Browse files Browse the repository at this point in the history
migrate from deprecated ioutil dependency
  • Loading branch information
magiconair authored Dec 7, 2024
2 parents c9a06e8 + 5478cd7 commit 52d9efe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 3 additions & 3 deletions load.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package properties

import (
"fmt"
"io/ioutil"
"io"
"net/http"
"os"
"strings"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}
Expand Down
5 changes: 2 additions & 3 deletions load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package properties

import (
"fmt"
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 52d9efe

Please sign in to comment.