1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2026-01-27 20:45:56 +00:00

Replace uses of ioutil

ioutil package was deprecated in Go 1.16, replace all uses with their
respective replacements.

This patch was generated with a combination of `gofmt -r`, `eg`, and
manually (for `ioutil.ReadDir`).
This commit is contained in:
Alberto Bertogli
2022-11-12 20:02:52 +00:00
parent 008367d320
commit 3ebe5c5173
22 changed files with 42 additions and 61 deletions

View File

@@ -8,7 +8,6 @@ import (
"flag"
"fmt"
"io"
"io/ioutil"
"math/rand"
"net"
"net/mail"
@@ -637,7 +636,7 @@ func (c *Conn) DATA(params string) (code int, msg string) {
// Create a dot reader, limited to the maximum size.
dotr := textproto.NewReader(bufio.NewReader(
io.LimitReader(c.reader, c.maxDataSize))).DotReader()
c.data, err = ioutil.ReadAll(dotr)
c.data, err = io.ReadAll(dotr)
if err != nil {
if err == io.ErrUnexpectedEOF {
// Message is too big already. But we need to keep reading until we see

View File

@@ -17,7 +17,6 @@ import (
"flag"
"fmt"
"io"
"io/ioutil"
"math/big"
"net"
"net/textproto"
@@ -235,7 +234,7 @@ func init() {
log.Default.Level = log.Error
// Generate certificates in a temporary directory.
tmpDir, err := ioutil.TempDir("", "chasquid_smtpsrv_fuzz:")
tmpDir, err := os.MkdirTemp("", "chasquid_smtpsrv_fuzz:")
if err != nil {
panic(fmt.Errorf("Failed to create temp dir: %v\n", tmpDir))
}

View File

@@ -4,7 +4,6 @@ import (
"crypto/tls"
"flag"
"fmt"
"io/ioutil"
"net"
"net/smtp"
"os"
@@ -568,7 +567,7 @@ func realMain(m *testing.M) int {
}
} else {
// Generate certificates in a temporary directory.
tmpDir, err := ioutil.TempDir("", "chasquid_test:")
tmpDir, err := os.MkdirTemp("", "chasquid_test:")
if err != nil {
fmt.Printf("Failed to create temp dir: %v\n", tmpDir)
return 1