Skip to content

Commit

Permalink
Remove references to deprecated ioutil.
Browse files Browse the repository at this point in the history
  • Loading branch information
knadh committed Mar 13, 2024
1 parent 5d92d94 commit 473c302
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
5 changes: 2 additions & 3 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"net/url"
Expand Down Expand Up @@ -172,11 +171,11 @@ func (c *Client) doHTTPReq(method, rURI string, reqBody interface{}, headers htt
}
defer func() {
// Drain and close the body to let the Transport reuse the connection
io.Copy(ioutil.Discard, r.Body)
io.Copy(io.Discard, r.Body)
r.Body.Close()
}()

body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
if err != nil {
return fmt.Errorf("error reading response: %v", err)
}
Expand Down
3 changes: 1 addition & 2 deletions cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"embed"
"errors"
"fmt"
"io/ioutil"
"os"
)

Expand All @@ -24,7 +23,7 @@ func generateConfig() error {
return fmt.Errorf("error reading sample config: %v", err)
}

if err := ioutil.WriteFile("config.toml", b, 0644); err != nil {
if err := os.WriteFile("config.toml", b, 0644); err != nil {
return err
}

Expand Down
3 changes: 1 addition & 2 deletions cmd/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
Expand Down Expand Up @@ -193,7 +192,7 @@ func testRequest(t *testing.T, method, path string, body io.Reader, dest interfa
resp := httptest.NewRecorder()
testRouter.ServeHTTP(resp, req)

respBody, err := ioutil.ReadAll(resp.Body)
respBody, err := io.ReadAll(resp.Body)
if err != nil {
t.Fatal(err)
return ""
Expand Down

0 comments on commit 473c302

Please sign in to comment.