Do not use ioutil as it is deprecated (#2625)

This commit is contained in:
Neil Alexander 2022-08-05 10:26:59 +01:00 committed by GitHub
parent 1b7f84250a
commit c8935fb53f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 52 additions and 60 deletions

View file

@ -19,8 +19,8 @@ import (
"encoding/pem"
"fmt"
"io"
"io/ioutil"
"net/url"
"os"
"path/filepath"
"regexp"
"strings"
@ -191,7 +191,7 @@ type ConfigErrors []string
// Load a yaml config file for a server run as multiple processes or as a monolith.
// Checks the config to ensure that it is valid.
func Load(configPath string, monolith bool) (*Dendrite, error) {
configData, err := ioutil.ReadFile(configPath)
configData, err := os.ReadFile(configPath)
if err != nil {
return nil, err
}
@ -199,9 +199,9 @@ func Load(configPath string, monolith bool) (*Dendrite, error) {
if err != nil {
return nil, err
}
// Pass the current working directory and ioutil.ReadFile so that they can
// Pass the current working directory and os.ReadFile so that they can
// be mocked in the tests
return loadConfig(basePath, configData, ioutil.ReadFile, monolith)
return loadConfig(basePath, configData, os.ReadFile, monolith)
}
func loadConfig(
@ -530,7 +530,7 @@ func (config *Dendrite) KeyServerURL() string {
// SetupTracing configures the opentracing using the supplied configuration.
func (config *Dendrite) SetupTracing(serviceName string) (closer io.Closer, err error) {
if !config.Tracing.Enabled {
return ioutil.NopCloser(bytes.NewReader([]byte{})), nil
return io.NopCloser(bytes.NewReader([]byte{})), nil
}
return config.Tracing.Jaeger.InitGlobalTracer(
serviceName,

View file

@ -16,7 +16,7 @@ package config
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"regexp"
"strings"
@ -181,7 +181,7 @@ func loadAppServices(config *AppServiceAPI, derived *Derived) error {
}
// Read the application service's config file
configData, err := ioutil.ReadFile(absPath)
configData, err := os.ReadFile(absPath)
if err != nil {
return err
}