Remove ioutil import

This commit is contained in:
180909 2023-10-21 23:49:19 +08:00 committed by Soren L. Hansen
parent bf3eae1d9a
commit 546ac8d62b
4 changed files with 8 additions and 9 deletions

View File

@ -3,7 +3,7 @@ package main
import (
"context"
"fmt"
"io/ioutil"
"io"
"log"
"os"
"os/signal"
@ -68,7 +68,7 @@ func main() {
if appOptions.Quiet {
log.SetFlags(0)
log.SetOutput(ioutil.Discard)
log.SetOutput(io.Discard)
}
if c.IsSet("credential") {

View File

@ -6,10 +6,10 @@ import (
"crypto/x509"
"html/template"
"io/fs"
"io/ioutil"
"log"
"net"
"net/http"
"os"
"regexp"
"strings"
noesctmpl "text/template"
@ -45,7 +45,7 @@ func New(factory Factory, options *Options) (*Server, error) {
}
if options.IndexFile != "" {
path := homedir.Expand(options.IndexFile)
indexData, err = ioutil.ReadFile(path)
indexData, err = os.ReadFile(path)
if err != nil {
return nil, errors.Wrapf(err, "failed to read custom index file at `%s`", path)
}
@ -253,7 +253,7 @@ func (server *Server) setupHTTPServer(handler http.Handler) (*http.Server, error
func (server *Server) tlsConfig() (*tls.Config, error) {
caFile := homedir.Expand(server.options.TLSCACrtFile)
caCert, err := ioutil.ReadFile(caFile)
caCert, err := os.ReadFile(caFile)
if err != nil {
return nil, errors.New("could not open CA crt file " + caFile)
}

View File

@ -1,7 +1,7 @@
package server
import (
"io/ioutil"
"io"
"github.com/gorilla/websocket"
"github.com/pkg/errors"
@ -31,7 +31,7 @@ func (wsw *wsWrapper) Read(p []byte) (n int, err error) {
continue
}
b, err := ioutil.ReadAll(reader)
b, err := io.ReadAll(reader)
if len(b) > len(p) {
return 0, errors.Wrapf(err, "Client message exceeded buffer size")
}

View File

@ -1,7 +1,6 @@
package utils
import (
"io/ioutil"
"log"
"os"
"reflect"
@ -114,7 +113,7 @@ func ApplyConfigFile(filePath string, options ...interface{}) error {
fileString := []byte{}
log.Printf("Loading config file at: %s", filePath)
fileString, err := ioutil.ReadFile(filePath)
fileString, err := os.ReadFile(filePath)
if err != nil {
return err
}