Move from deprecated ioutil to os and io packages (#744)

This commit is contained in:
KallyDev 2021-09-29 02:49:34 +08:00 committed by GitHub
parent 1ef824c0b4
commit 4abf98c1be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 29 additions and 43 deletions

View file

@ -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