Update deprecated io/ioutil functions

ioutil has been deprecated since go 1.16, this fixes all of the
deprecated functions we are using:

ioutil.ReadFile -> os.ReadFile
ioutil.ReadAll -> io.ReadAll
ioutil.WriteFile -> os.WriteFile
ioutil.TempFile -> os.CreateTemp
ioutil.TempDir -> os.MkdirTemp

All of the above are a simple name change, the function arguments and
results are exactly the same as before.

ioutil.ReadDir -> os.ReadDir

now returns a os.DirEntry but the IsDir and Name functions work the
same. The difference is that the FileInfo must be retrieved with the
Info() function which can also return an error.

These were identified by running:
golangci-lint run --build-tags=integration ./...
This commit is contained in:
Brian C. Lane 2023-03-06 11:07:30 -08:00 committed by Brian C. Lane
parent 0e4a5b34b2
commit 7a4bb863dd
37 changed files with 113 additions and 126 deletions

View file

@ -6,7 +6,6 @@ import (
"crypto/x509"
"errors"
"fmt"
"io/ioutil"
"log"
"net"
"net/http"
@ -389,7 +388,7 @@ func createTLSConfig(c *connectionConfig) (*tls.Config, error) {
var roots *x509.CertPool
if c.CACertFile != "" {
caCertPEM, err := ioutil.ReadFile(c.CACertFile)
caCertPEM, err := os.ReadFile(c.CACertFile)
if err != nil {
return nil, err
}