diff --git a/common/buf/multi_buffer_test.go b/common/buf/multi_buffer_test.go index 6d835c828..c4c85c38e 100644 --- a/common/buf/multi_buffer_test.go +++ b/common/buf/multi_buffer_test.go @@ -4,7 +4,6 @@ import ( "bytes" "crypto/rand" "io" - "io/ioutil" "os" "testing" @@ -120,7 +119,7 @@ func TestMultiBufferReadAllToByte(t *testing.T) { common.Must(err) f.Close() - cnt, err := ioutil.ReadFile(dat) + cnt, err := os.ReadFile(dat) common.Must(err) if d := cmp.Diff(buf2, cnt); d != "" { diff --git a/common/cmdarg/arg.go b/common/cmdarg/arg.go index 8a0958d42..52ccb7d6f 100644 --- a/common/cmdarg/arg.go +++ b/common/cmdarg/arg.go @@ -3,7 +3,7 @@ package cmdarg import ( "bytes" "io" - "io/ioutil" + "os" ) // LoadArg loads one arg, maybe an remote url, or local file path @@ -18,7 +18,7 @@ func LoadArg(arg string) (out io.Reader, err error) { // LoadArgToBytes loads one arg to []byte, maybe an remote url, or local file path func LoadArgToBytes(arg string) (out []byte, err error) { - out, err = ioutil.ReadFile(arg) + out, err = os.ReadFile(arg) if err != nil { return } diff --git a/common/log/logger_test.go b/common/log/logger_test.go index 3e430226a..aa130ba99 100644 --- a/common/log/logger_test.go +++ b/common/log/logger_test.go @@ -1,7 +1,6 @@ package log_test import ( - "io/ioutil" "os" "strings" "testing" @@ -13,7 +12,7 @@ import ( ) func TestFileLogger(t *testing.T) { - f, err := ioutil.TempFile("", "vtest") + f, err := os.CreateTemp("", "vtest") common.Must(err) path := f.Name() common.Must(f.Close()) diff --git a/infra/conf/geodata/memconservative/cache.go b/infra/conf/geodata/memconservative/cache.go index 386086cb7..307db9d68 100644 --- a/infra/conf/geodata/memconservative/cache.go +++ b/infra/conf/geodata/memconservative/cache.go @@ -1,7 +1,7 @@ package memconservative import ( - "io/ioutil" + "os" "strings" "google.golang.org/protobuf/proto" @@ -53,7 +53,7 @@ func (g GeoIPCache) Unmarshal(filename, code string) (*routercommon.GeoIP, error case errFailedToReadBytes, errFailedToReadExpectedLenBytes, errInvalidGeodataFile, errInvalidGeodataVarintLength: newError("failed to decode geoip file: ", filename, ", fallback to the original ReadFile method") - geoipBytes, err = ioutil.ReadFile(asset) + geoipBytes, err = os.ReadFile(asset) if err != nil { return nil, err } @@ -118,7 +118,7 @@ func (g GeoSiteCache) Unmarshal(filename, code string) (*routercommon.GeoSite, e case errFailedToReadBytes, errFailedToReadExpectedLenBytes, errInvalidGeodataFile, errInvalidGeodataVarintLength: newError("failed to decode geoip file: ", filename, ", fallback to the original ReadFile method") - geositeBytes, err = ioutil.ReadFile(asset) + geositeBytes, err = os.ReadFile(asset) if err != nil { return nil, err } diff --git a/infra/vprotogen/main.go b/infra/vprotogen/main.go index 2551808ca..df78fa657 100644 --- a/infra/vprotogen/main.go +++ b/infra/vprotogen/main.go @@ -6,7 +6,6 @@ import ( "fmt" "go/build" "io" - "io/ioutil" "net/http" "os" "os/exec" @@ -48,7 +47,7 @@ func GetRuntimeEnv(key string) (string, error) { } var data []byte var runtimeEnv string - data, readErr := ioutil.ReadFile(file) + data, readErr := os.ReadFile(file) if readErr != nil { return "", readErr } diff --git a/main/commands/helpers/fs.go b/main/commands/helpers/fs.go index 855ee19b7..542a52ed6 100644 --- a/main/commands/helpers/fs.go +++ b/main/commands/helpers/fs.go @@ -2,7 +2,6 @@ package helpers import ( "fmt" - "io/ioutil" "os" "path/filepath" "strings" @@ -10,7 +9,7 @@ import ( // ReadDir finds files according to extensions in the dir func ReadDir(dir string, extensions []string) ([]string, error) { - confs, err := ioutil.ReadDir(dir) + confs, err := os.ReadDir(dir) if err != nil { return nil, err } diff --git a/main/commands/run.go b/main/commands/run.go index 1e88b84b9..066bfae18 100644 --- a/main/commands/run.go +++ b/main/commands/run.go @@ -2,7 +2,6 @@ package commands import ( "fmt" - "io/ioutil" "log" "os" "os/signal" @@ -113,7 +112,7 @@ func dirExists(file string) bool { } func readConfDir(dirPath string, extension []string) cmdarg.Arg { - confs, err := ioutil.ReadDir(dirPath) + confs, err := os.ReadDir(dirPath) if err != nil { base.Fatalf("failed to read dir %s: %s", dirPath, err) }