diff --git a/config/config.go b/config/config.go index f4b84c0..7810e15 100644 --- a/config/config.go +++ b/config/config.go @@ -2,7 +2,6 @@ package config import ( "fmt" - "io/ioutil" "log/syslog" "os" "time" @@ -671,7 +670,7 @@ func ParseConfig(path string) (i *Config, err error) { var bytes []byte - if bytes, err = ioutil.ReadFile(path); err != nil { + if bytes, err = os.ReadFile(path); err != nil { return } diff --git a/platformtest/platformtest_ops.go b/platformtest/platformtest_ops.go index c4f1773..9c1e166 100644 --- a/platformtest/platformtest_ops.go +++ b/platformtest/platformtest_ops.go @@ -5,7 +5,6 @@ import ( "bytes" "context" "fmt" - "io/ioutil" "os" "os/exec" "strings" @@ -64,7 +63,7 @@ func (o *FSOp) Run(ctx context.Context, e Execer) error { if o.Encrypted { const passphraseFilePath = "/tmp/zreplplatformtest.encryption.passphrase" const passphrase = "foobar2342" - err := ioutil.WriteFile(passphraseFilePath, []byte(passphrase), 0600) + err := os.WriteFile(passphraseFilePath, []byte(passphrase), 0600) if err != nil { panic(err) } diff --git a/platformtest/tests/gen/gen.go b/platformtest/tests/gen/gen.go index 4d75871..3147297 100644 --- a/platformtest/tests/gen/gen.go +++ b/platformtest/tests/gen/gen.go @@ -6,7 +6,6 @@ import ( "go/format" "go/parser" "go/token" - "io/ioutil" "os" "sort" "strings" @@ -132,7 +131,7 @@ var Cases = []Case { formatted, err := format.Source(buf.Bytes()) check(err) - err = ioutil.WriteFile("generated_cases.go", formatted, 0664) + err = os.WriteFile("generated_cases.go", formatted, 0664) check(err) } diff --git a/platformtest/tests/sendStream.go b/platformtest/tests/sendStream.go index 7fbe5e7..019d5c8 100644 --- a/platformtest/tests/sendStream.go +++ b/platformtest/tests/sendStream.go @@ -3,7 +3,6 @@ package tests import ( "fmt" "io" - "io/ioutil" "os" "os/exec" "path" @@ -102,7 +101,7 @@ func SendStreamCloseAfterEOFRead(ctx *platformtest.Context) { sendStream := sendStreamTest(ctx) - _, err := io.Copy(ioutil.Discard, sendStream) + _, err := io.Copy(io.Discard, sendStream) require.NoError(ctx, err) var buf [128]byte @@ -122,7 +121,7 @@ func SendStreamMultipleCloseAfterEOF(ctx *platformtest.Context) { sendStream := sendStreamTest(ctx) - _, err := io.Copy(ioutil.Discard, sendStream) + _, err := io.Copy(io.Discard, sendStream) require.NoError(ctx, err) var buf [128]byte diff --git a/rpc/dataconn/frameconn/frameconn.go b/rpc/dataconn/frameconn/frameconn.go index dccf417..96ec273 100644 --- a/rpc/dataconn/frameconn/frameconn.go +++ b/rpc/dataconn/frameconn/frameconn.go @@ -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") diff --git a/rpc/dataconn/timeoutconn/internal/wireevaluator/wireevaluator.go b/rpc/dataconn/timeoutconn/internal/wireevaluator/wireevaluator.go index 29b0462..c786dba 100644 --- a/rpc/dataconn/timeoutconn/internal/wireevaluator/wireevaluator.go +++ b/rpc/dataconn/timeoutconn/internal/wireevaluator/wireevaluator.go @@ -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) diff --git a/rpc/dataconn/timeoutconn/internal/wireevaluator/wireevaluator_closewrite.go b/rpc/dataconn/timeoutconn/internal/wireevaluator/wireevaluator_closewrite.go index e2dddbd..670486e 100644 --- a/rpc/dataconn/timeoutconn/internal/wireevaluator/wireevaluator_closewrite.go +++ b/rpc/dataconn/timeoutconn/internal/wireevaluator/wireevaluator_closewrite.go @@ -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) diff --git a/tlsconf/tlsconf.go b/tlsconf/tlsconf.go index 71e81c0..85b8dc9 100644 --- a/tlsconf/tlsconf.go +++ b/tlsconf/tlsconf.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "net" "os" "time" @@ -14,7 +13,7 @@ import ( func ParseCAFile(certfile string) (*x509.CertPool, error) { pool := x509.NewCertPool() - pem, err := ioutil.ReadFile(certfile) + pem, err := os.ReadFile(certfile) if err != nil { return nil, err } diff --git a/zfs/zfs_pipe_linux.go b/zfs/zfs_pipe_linux.go index 104997c..e52d5e1 100644 --- a/zfs/zfs_pipe_linux.go +++ b/zfs/zfs_pipe_linux.go @@ -3,7 +3,6 @@ package zfs import ( "errors" "fmt" - "io/ioutil" "os" "strconv" "strings" @@ -20,7 +19,7 @@ func getPipeCapacityHint(envvar string) int { // https://github.com/zrepl/zrepl/issues/424#issuecomment-800370928 // https://bugzilla.kernel.org/show_bug.cgi?id=212295 if _, err := os.Stat("/proc/sys/fs/pipe-max-size"); err == nil { - if dat, err := ioutil.ReadFile("/proc/sys/fs/pipe-max-size"); err == nil { + if dat, err := os.ReadFile("/proc/sys/fs/pipe-max-size"); err == nil { if capacity, err = strconv.ParseInt(strings.TrimSpace(string(dat)), 10, 64); err != nil { capacity = 1 << 25 }