Skip to content

Commit

Permalink
fix: 替换弃用的方法。
Browse files Browse the repository at this point in the history
  • Loading branch information
lanyulei committed Nov 18, 2024
1 parent 626f169 commit 1c2ed68
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion apis/process/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions models/system/initdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package system
import (
"ferry/global/orm"
"fmt"
"io/ioutil"
"os"
"strings"
)

Expand Down Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions tools/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package config
import (
"ferry/pkg/logger"
"fmt"
"io/ioutil"
"os"
"strings"

Expand All @@ -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()))
}
Expand Down

0 comments on commit 1c2ed68

Please sign in to comment.