diff --git a/client.go b/client.go index 3e738a2..c19152f 100644 --- a/client.go +++ b/client.go @@ -6,7 +6,7 @@ import ( "encoding/base64" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "time" @@ -100,7 +100,7 @@ func callAutograph(auth authorization, body []byte, xff string) (signedBody []by return } defer resp.Body.Close() - respBody, err := ioutil.ReadAll(resp.Body) + respBody, err := io.ReadAll(resp.Body) if err != nil { return } diff --git a/handlers_test.go b/handlers_test.go index 1c54780..d98fed1 100644 --- a/handlers_test.go +++ b/handlers_test.go @@ -3,7 +3,7 @@ package main import ( "bytes" "fmt" - "io/ioutil" + "io" "net/http" "net/http/httptest" "os" @@ -39,7 +39,7 @@ func Test_heartbeatHandler(t *testing.T) { upstreamResponse: &http.Response{ Status: http.StatusText(http.StatusOK), StatusCode: http.StatusOK, - Body: ioutil.NopCloser(bytes.NewReader([]byte("{}"))), + Body: io.NopCloser(bytes.NewReader([]byte("{}"))), }, upstreamErr: nil, expectedResponse: expectedResponse{ @@ -57,7 +57,7 @@ func Test_heartbeatHandler(t *testing.T) { upstreamResponse: &http.Response{ Status: http.StatusText(http.StatusBadGateway), StatusCode: http.StatusBadGateway, - Body: ioutil.NopCloser(bytes.NewReader([]byte("{}"))), + Body: io.NopCloser(bytes.NewReader([]byte("{}"))), }, upstreamErr: nil, expectedResponse: expectedResponse{ @@ -100,7 +100,7 @@ func Test_heartbeatHandler(t *testing.T) { heartbeatHandler(tt.args.baseURL, client)(w, tt.args.r) resp := w.Result() - body, _ := ioutil.ReadAll(resp.Body) + body, _ := io.ReadAll(resp.Body) if resp.StatusCode != tt.expectedResponse.status { t.Fatalf("heartbeatHandler() returned unexpected status %v expected %v", resp.StatusCode, tt.expectedResponse.status) @@ -122,7 +122,7 @@ func TestVersion(t *testing.T) { versionHandler(w, req) resp := w.Result() - body, _ := ioutil.ReadAll(resp.Body) + body, _ := io.ReadAll(resp.Body) if resp.StatusCode != http.StatusOK { t.Fatalf("returned unexpected status %v expected %v", resp.StatusCode, http.StatusOK) @@ -141,7 +141,7 @@ func TestNotFoundHandler(t *testing.T) { notFoundHandler(w, req) resp := w.Result() - body, _ := ioutil.ReadAll(resp.Body) + body, _ := io.ReadAll(resp.Body) if resp.StatusCode != http.StatusNotFound { t.Fatalf("returned unexpected status %v expected %v", resp.StatusCode, http.StatusOK) diff --git a/main.go b/main.go index c199934..bea6fbb 100644 --- a/main.go +++ b/main.go @@ -6,9 +6,9 @@ import ( "flag" "fmt" "io" - "io/ioutil" "net/http" "net/url" + "os" "strings" "github.com/pkg/errors" @@ -153,7 +153,7 @@ func prepareServer(host string, port int) *http.Server { // loadFromFile reads a configuration from a local file func (c *configuration) loadFromFile(path string) error { var confData []byte - data, err := ioutil.ReadFile(path) + data, err := os.ReadFile(path) if err != nil { return err } @@ -196,7 +196,7 @@ func httpError(w http.ResponseWriter, r *http.Request, errorCode int, errorMessa // request body is read before writing a response. // https://github.com/golang/go/issues/15789 if r.Body != nil { - io.Copy(ioutil.Discard, r.Body) + io.Copy(io.Discard, r.Body) r.Body.Close() } http.Error(w, msg, errorCode) diff --git a/main_test.go b/main_test.go index df8bc55..9e40bd4 100644 --- a/main_test.go +++ b/main_test.go @@ -4,7 +4,6 @@ import ( "bytes" "fmt" "io" - "io/ioutil" "log" "net/http" "net/http/httptest" @@ -567,7 +566,7 @@ Content-Type: application/octet-stream req, err := http.NewRequest( tt.method, fmt.Sprintf(testServer.URL+tt.path), - ioutil.NopCloser(bytes.NewReader(tt.body)), + io.NopCloser(bytes.NewReader(tt.body)), ) if err != nil { t.Fatal(err)