No longer use ioutil which is deprecated

This commit is contained in:
Neil Alexander 2022-08-06 15:21:21 +01:00
parent d5c0dc9bee
commit 16b8149052
3 changed files with 6 additions and 7 deletions

View File

@ -8,7 +8,7 @@ import (
"encoding/json" "encoding/json"
"flag" "flag"
"fmt" "fmt"
"io/ioutil" "io"
"net" "net"
"os" "os"
"os/signal" "os/signal"
@ -51,10 +51,10 @@ func readConfig(log *log.Logger, useconf bool, useconffile string, normaliseconf
var err error var err error
if useconffile != "" { if useconffile != "" {
// Read the file from the filesystem // Read the file from the filesystem
conf, err = ioutil.ReadFile(useconffile) conf, err = os.ReadFile(useconffile)
} else { } else {
// Read the file from stdin. // Read the file from stdin.
conf, err = ioutil.ReadAll(os.Stdin) conf, err = io.ReadAll(os.Stdin)
} }
if err != nil { if err != nil {
panic(err) panic(err)

View File

@ -4,7 +4,6 @@ import (
"bytes" "bytes"
"flag" "flag"
"fmt" "fmt"
"io/ioutil"
"log" "log"
"os" "os"
@ -61,7 +60,7 @@ func (cmdLineEnv *CmdLineEnv) parseFlagsAndArgs() {
func (cmdLineEnv *CmdLineEnv) setEndpoint(logger *log.Logger) { func (cmdLineEnv *CmdLineEnv) setEndpoint(logger *log.Logger) {
if cmdLineEnv.server == cmdLineEnv.endpoint { if cmdLineEnv.server == cmdLineEnv.endpoint {
if config, err := ioutil.ReadFile(defaults.GetDefaults().DefaultConfigFile); err == nil { if config, err := os.ReadFile(defaults.GetDefaults().DefaultConfigFile); err == nil {
if bytes.Equal(config[0:2], []byte{0xFF, 0xFE}) || if bytes.Equal(config[0:2], []byte{0xFF, 0xFE}) ||
bytes.Equal(config[0:2], []byte{0xFE, 0xFF}) { bytes.Equal(config[0:2], []byte{0xFE, 0xFF}) {
utf := unicode.UTF16(unicode.BigEndian, unicode.UseBOM) utf := unicode.UTF16(unicode.BigEndian, unicode.UseBOM)

View File

@ -6,7 +6,7 @@ import (
"encoding/hex" "encoding/hex"
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io"
"net" "net"
"net/url" "net/url"
"time" "time"
@ -48,7 +48,7 @@ func (c *Core) _init() error {
c.config.RLock() c.config.RLock()
defer c.config.RUnlock() defer c.config.RUnlock()
if c.log == nil { if c.log == nil {
c.log = log.New(ioutil.Discard, "", 0) c.log = log.New(io.Discard, "", 0)
} }
sigPriv, err := hex.DecodeString(c.config.PrivateKey) sigPriv, err := hex.DecodeString(c.config.PrivateKey)