Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate from deprecated ioutil dependency #73

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions load.go
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
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