mirror of https://github.com/jackc/pgx.git
Replace deprecated "io/ioutil"
ioutil.TempFile: Deprecated: As of Go 1.17, this function simply calls os.CreateTemp. ioutil.ReadFile: Deprecated: As of Go 1.16, this function simply calls os.ReadFile.pull/1477/head
parent
7c0c7dc01e
commit
672431c0bd
|
@ -8,7 +8,6 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"net"
|
||||
"net/url"
|
||||
|
@ -687,7 +686,7 @@ func configTLS(settings map[string]string, thisHost string, parseConfigOptions P
|
|||
caCertPool := x509.NewCertPool()
|
||||
|
||||
caPath := sslrootcert
|
||||
caCert, err := ioutil.ReadFile(caPath)
|
||||
caCert, err := os.ReadFile(caPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to read CA file: %w", err)
|
||||
}
|
||||
|
@ -705,7 +704,7 @@ func configTLS(settings map[string]string, thisHost string, parseConfigOptions P
|
|||
}
|
||||
|
||||
if sslcert != "" && sslkey != "" {
|
||||
buf, err := ioutil.ReadFile(sslkey)
|
||||
buf, err := os.ReadFile(sslkey)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to read sslkey: %w", err)
|
||||
}
|
||||
|
@ -744,7 +743,7 @@ func configTLS(settings map[string]string, thisHost string, parseConfigOptions P
|
|||
} else {
|
||||
pemKey = pem.EncodeToMemory(block)
|
||||
}
|
||||
certfile, err := ioutil.ReadFile(sslcert)
|
||||
certfile, err := os.ReadFile(sslcert)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to read cert: %w", err)
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
"context"
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/user"
|
||||
"runtime"
|
||||
|
@ -1031,7 +1030,7 @@ func TestParseConfigEnvLibpq(t *testing.T) {
|
|||
func TestParseConfigReadsPgPassfile(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tf, err := ioutil.TempFile("", "")
|
||||
tf, err := os.CreateTemp("", "")
|
||||
require.NoError(t, err)
|
||||
|
||||
defer tf.Close()
|
||||
|
@ -1060,7 +1059,7 @@ func TestParseConfigReadsPgPassfile(t *testing.T) {
|
|||
func TestParseConfigReadsPgServiceFile(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tf, err := ioutil.TempFile("", "")
|
||||
tf, err := os.CreateTemp("", "")
|
||||
require.NoError(t, err)
|
||||
|
||||
defer tf.Close()
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"math"
|
||||
"net"
|
||||
|
@ -1819,7 +1818,7 @@ func TestConnCopyFromGzipReader(t *testing.T) {
|
|||
)`).ReadAll()
|
||||
require.NoError(t, err)
|
||||
|
||||
f, err := ioutil.TempFile("", "*")
|
||||
f, err := os.CreateTemp("", "*")
|
||||
require.NoError(t, err)
|
||||
|
||||
gw := gzip.NewWriter(f)
|
||||
|
|
Loading…
Reference in New Issue