mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-21 17:46:58 -05:00
chore: remove refs to deprecated io/ioutil (#2717)
Signed-off-by: guoguangwu <guoguangwu@magic-shield.com>
This commit is contained in:
parent
b617c97342
commit
39d2f293c6
@ -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 != "" {
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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())
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user