diff --git a/apis/process/task.go b/apis/process/task.go index 64827a56..07ea7c5c 100644 --- a/apis/process/task.go +++ b/apis/process/task.go @@ -229,7 +229,7 @@ func TaskDetails(c *gin.Context) { return } - content, err = ioutil.ReadFile(fmt.Sprintf("%v/%v", viper.GetString("script.path"), fileName)) + content, err = os.ReadFile(fmt.Sprintf("%v/%v", viper.GetString("script.path"), fileName)) if err != nil { return } diff --git a/models/system/initdb.go b/models/system/initdb.go index 5f521e8b..ec32c7b2 100644 --- a/models/system/initdb.go +++ b/models/system/initdb.go @@ -3,7 +3,7 @@ package system import ( "ferry/global/orm" "fmt" - "io/ioutil" + "os" "strings" ) @@ -35,7 +35,7 @@ func InitDb() error { } func Ioutil(name string) (string, error) { - if contents, err := ioutil.ReadFile(name); err == nil { + if contents, err := os.ReadFile(name); err == nil { //因为contents是[]byte类型,直接转换成string类型后会多一行空格,需要使用strings.Replace替换换行符 result := strings.Replace(string(contents), "\n", "", 1) return result, nil diff --git a/tools/config/config.go b/tools/config/config.go index 17fe33e8..3fbad696 100644 --- a/tools/config/config.go +++ b/tools/config/config.go @@ -3,7 +3,6 @@ package config import ( "ferry/pkg/logger" "fmt" - "io/ioutil" "os" "strings" @@ -15,10 +14,10 @@ var cfgApplication *viper.Viper var cfgJwt *viper.Viper var cfgSsl *viper.Viper -//载入配置文件 +// ConfigSetup 载入配置文件 func ConfigSetup(path string) { viper.SetConfigFile(path) - content, err := ioutil.ReadFile(path) + content, err := os.ReadFile(path) if err != nil { logger.Fatal(fmt.Sprintf("Read config file fail: %s", err.Error())) }