mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-29 16:58:34 +00:00
Move from deprecated ioutil to os and io packages (#744)
This commit is contained in:
parent
1ef824c0b4
commit
4abf98c1be
17 changed files with 29 additions and 43 deletions
|
@ -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 != "" {
|
||||
|
|
|
@ -5,7 +5,6 @@ package common
|
|||
import (
|
||||
"fmt"
|
||||
"go/build"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
@ -69,7 +68,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
|
||||
}
|
||||
|
@ -131,7 +130,7 @@ func GetModuleName(pathToProjectRoot string) (string, error) {
|
|||
for {
|
||||
if idx := strings.LastIndex(loopPath, string(filepath.Separator)); idx >= 0 {
|
||||
gomodPath := filepath.Join(loopPath, "go.mod")
|
||||
gomodBytes, err := ioutil.ReadFile(gomodPath)
|
||||
gomodBytes, err := os.ReadFile(gomodPath)
|
||||
if err != nil {
|
||||
loopPath = loopPath[:idx]
|
||||
continue
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"bytes"
|
||||
"crypto/x509"
|
||||
"encoding/pem"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
|
@ -74,7 +74,7 @@ func GetOCSPForCert(cert [][]byte) ([]byte, error) {
|
|||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
issuerBytes, errC := ioutil.ReadAll(resp.Body)
|
||||
issuerBytes, errC := io.ReadAll(resp.Body)
|
||||
if errC != nil {
|
||||
return nil, newError(errC)
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ func GetOCSPForCert(cert [][]byte) ([]byte, error) {
|
|||
return nil, newError(err)
|
||||
}
|
||||
defer req.Body.Close()
|
||||
ocspResBytes, err := ioutil.ReadAll(req.Body)
|
||||
ocspResBytes, err := io.ReadAll(req.Body)
|
||||
|
||||
if err != nil {
|
||||
return nil, newError(err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue