Skip to content

Commit

Permalink
Stop using deprecated ioutil package
Browse files Browse the repository at this point in the history
  • Loading branch information
rafiss committed Mar 2, 2023
1 parent e47acb6 commit ad4962b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
3 changes: 1 addition & 2 deletions testserver/binaries.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"net/url"
Expand Down Expand Up @@ -348,7 +347,7 @@ func downloadBinaryFromTar(response *http.Response, output *os.File, filePath st
// It is created because the download url from the release page only provides the tar.gz/zip
// for a pre-compiled binary.
func downloadBinaryFromZip(response *http.Response, output *os.File, filePath string) error {
body, err := ioutil.ReadAll(response.Body)
body, err := io.ReadAll(response.Body)
if err != nil {
return fmt.Errorf("cannot read zip from response body: %w", err)
}
Expand Down
7 changes: 3 additions & 4 deletions testserver/testserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import (
"errors"
"flag"
"fmt"
"io/ioutil"
"log"
"net/url"
"os"
Expand Down Expand Up @@ -458,7 +457,7 @@ func NewTestServer(opts ...TestServerOpt) (TestServer, error) {

// Force "/tmp/" so avoid OSX's really long temp directory names
// which get us over the socket filename length limit.
baseDir, err := ioutil.TempDir("/tmp", "cockroach-testserver")
baseDir, err := os.MkdirTemp("/tmp", "cockroach-testserver")
if err != nil {
return nil, fmt.Errorf("%s: could not create temp directory: %w",
testserverMessagePrefix, err)
Expand Down Expand Up @@ -726,7 +725,7 @@ func (ts *testServerImpl) pollListeningURLFile(nodeNum int) error {
return fmt.Errorf("server stopped or crashed before listening URL file was available")
}
var err error
data, err = ioutil.ReadFile(ts.nodes[nodeNum].listeningURLFile)
data, err = os.ReadFile(ts.nodes[nodeNum].listeningURLFile)
if len(data) == 0 {
time.Sleep(100 * time.Millisecond)
continue
Expand Down Expand Up @@ -929,7 +928,7 @@ func (w fileLogWriter) Write(p []byte) (n int, err error) {
}

func (w fileLogWriter) String() string {
b, err := ioutil.ReadFile(w.filename)
b, err := os.ReadFile(w.filename)
if err == nil {
return string(b)
}
Expand Down

0 comments on commit ad4962b

Please sign in to comment.