diff --git a/couchdb-exporter_test.go b/couchdb-exporter_test.go index dec35c56..f89e7c1d 100644 --- a/couchdb-exporter_test.go +++ b/couchdb-exporter_test.go @@ -3,12 +3,12 @@ package main import ( "encoding/base64" "fmt" - "io/ioutil" "log" "net" "net/http" "net/http/httptest" "net/url" + "os" "strings" "testing" "time" @@ -61,7 +61,7 @@ func BasicAuthHandler(basicAuth lib.BasicAuth, pass Handler) Handler { } func readFile(t *testing.T, filename string) []byte { - fileContent, err := ioutil.ReadFile(filename) + fileContent, err := os.ReadFile(filename) if err != nil { t.Errorf("Error reading file %s: %v\n", filename, err) } diff --git a/fileutil/properties_file_loader.go b/fileutil/properties_file_loader.go index 17104d2f..59a2f4e8 100644 --- a/fileutil/properties_file_loader.go +++ b/fileutil/properties_file_loader.go @@ -6,7 +6,7 @@ import ( "bufio" "bytes" "fmt" - "io/ioutil" + "io" "log" "net/http" "net/url" @@ -109,21 +109,21 @@ func loadDataFrom(filePath string) ([]byte, error) { if err != nil { return nil, err } - return ioutil.ReadAll(res.Body) + return io.ReadAll(res.Body) default: return nil, fmt.Errorf("scheme of %s is unsupported", filePath) } - } else if u.Path != "" { // i dont have a host, but I have a path. I am a local file. + } else if u.Path != "" { // I don't have a host, but I have a path. I am a local file. if _, notFoundFileErr := os.Stat(filePath); notFoundFileErr != nil { return nil, fmt.Errorf("cannot read from file: '%s' because it does not exist", filePath) } - return ioutil.ReadFile(filePath) + return os.ReadFile(filePath) } else if runtime.GOOS == "windows" && strings.Contains(u.String(), "\\") { // on Windows systems u.Path is always empty, so we need to check the string directly. if _, notFoundFileErr := os.Stat(filePath); notFoundFileErr != nil { return nil, fmt.Errorf("cannot read from file: '%s' because it does not exist", filePath) } - return ioutil.ReadFile(filePath) + return os.ReadFile(filePath) } else { return nil, fmt.Errorf("unable to determine how to load from path %s", filePath) } diff --git a/lib/couchdb-client.go b/lib/couchdb-client.go index 44a12f2b..8bf316c0 100644 --- a/lib/couchdb-client.go +++ b/lib/couchdb-client.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "net/http" "net/url" "strconv" @@ -575,7 +574,7 @@ func (c *CouchdbClient) Request(method string, uri string, body io.Reader) (resp }() } - respData, err = ioutil.ReadAll(resp.Body) + respData, err = io.ReadAll(resp.Body) if resp.StatusCode < 200 || resp.StatusCode >= 400 { if err != nil { respData = []byte(err.Error())