chore: io/ioutil has been deprecated
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"sync"
|
||||
"syscall"
|
||||
@@ -354,7 +353,7 @@ func (c *Conn) Shutdown(deadline time.Time) error {
|
||||
// TODO DoS mitigation by reading limited number of bytes
|
||||
// see discussion above why this is non-trivial
|
||||
defer prometheus.NewTimer(prom.ShutdownDrainSeconds).ObserveDuration()
|
||||
n, _ := io.Copy(ioutil.Discard, c.nc)
|
||||
n, _ := io.Copy(io.Discard, c.nc)
|
||||
prom.ShutdownDrainBytesRead.Observe(float64(n))
|
||||
|
||||
return closeWire("close")
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
|
||||
@@ -47,7 +46,7 @@ func main() {
|
||||
flag.StringVar(&args.testCase, "testcase", "", "")
|
||||
flag.Parse()
|
||||
|
||||
bytes, err := ioutil.ReadFile(args.configPath)
|
||||
bytes, err := os.ReadFile(args.configPath)
|
||||
noerror(err)
|
||||
err = yaml.UnmarshalStrict(bytes, &conf)
|
||||
noerror(err)
|
||||
|
||||
@@ -3,7 +3,6 @@ package main
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
|
||||
"github.com/zrepl/zrepl/transport"
|
||||
@@ -83,7 +82,7 @@ func (CloseWrite) receiver(wire transport.Wire) {
|
||||
// consume half the test data, then detect an error, send it and CloseWrite
|
||||
|
||||
r := io.LimitReader(wire, int64(5*len(closeWriteTestSendData)/3))
|
||||
_, err := io.Copy(ioutil.Discard, r)
|
||||
_, err := io.Copy(io.Discard, r)
|
||||
noerror(err)
|
||||
|
||||
var errBuf bytes.Buffer
|
||||
@@ -95,7 +94,7 @@ func (CloseWrite) receiver(wire transport.Wire) {
|
||||
noerror(err)
|
||||
|
||||
// drain wire, as documented in transport.Wire, this is the only way we know the client closed the conn
|
||||
_, err = io.Copy(ioutil.Discard, wire)
|
||||
_, err = io.Copy(io.Discard, wire)
|
||||
if err != nil {
|
||||
// io.Copy masks io.EOF to nil, and we expect io.EOF from the client's Close() call
|
||||
log.Panicf("unexpected error returned from reading conn: %s", err)
|
||||
|
||||
Reference in New Issue
Block a user