Skip to content

Commit ad4962b

Browse files
committed
Stop using deprecated ioutil package
1 parent e47acb6 commit ad4962b

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

testserver/binaries.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"errors"
2424
"fmt"
2525
"io"
26-
"io/ioutil"
2726
"log"
2827
"net/http"
2928
"net/url"
@@ -348,7 +347,7 @@ func downloadBinaryFromTar(response *http.Response, output *os.File, filePath st
348347
// It is created because the download url from the release page only provides the tar.gz/zip
349348
// for a pre-compiled binary.
350349
func downloadBinaryFromZip(response *http.Response, output *os.File, filePath string) error {
351-
body, err := ioutil.ReadAll(response.Body)
350+
body, err := io.ReadAll(response.Body)
352351
if err != nil {
353352
return fmt.Errorf("cannot read zip from response body: %w", err)
354353
}

testserver/testserver.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ import (
4343
"errors"
4444
"flag"
4545
"fmt"
46-
"io/ioutil"
4746
"log"
4847
"net/url"
4948
"os"
@@ -458,7 +457,7 @@ func NewTestServer(opts ...TestServerOpt) (TestServer, error) {
458457

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

931930
func (w fileLogWriter) String() string {
932-
b, err := ioutil.ReadFile(w.filename)
931+
b, err := os.ReadFile(w.filename)
933932
if err == nil {
934933
return string(b)
935934
}

0 commit comments

Comments
 (0)