io/ioutil deprecated (#3217)

This commit is contained in:
guangwu
2023-05-06 17:50:54 +08:00
committed by GitHub
parent 4f13fe8188
commit 63368d8b0c
27 changed files with 85 additions and 89 deletions

View File

@@ -2,7 +2,7 @@ package quickstart
import (
_ "embed"
"io/ioutil"
"os"
"path/filepath"
"github.com/zeromicro/go-zero/core/logx"
@@ -38,7 +38,7 @@ func initRPCProto() error {
protoFilename := filepath.Join(zrpcWorkDir, protoName)
rpcBytes := []byte(protocContent)
return ioutil.WriteFile(protoFilename, rpcBytes, 0o666)
return os.WriteFile(protoFilename, rpcBytes, 0o666)
}
type micro struct{}
@@ -55,7 +55,7 @@ func (m micro) mustStartRPCProject() {
arg := "goctl rpc protoc " + protoName + " --go_out=. --go-grpc_out=. --zrpc_out=. --verbose"
execCommand(zrpcWorkDir, arg)
etcFile := filepath.Join(zrpcWorkDir, "etc", "greet.yaml")
logx.Must(ioutil.WriteFile(etcFile, []byte(rpcEtcContent), 0o666))
logx.Must(os.WriteFile(etcFile, []byte(rpcEtcContent), 0o666))
}
func (m micro) start() {

View File

@@ -2,7 +2,7 @@ package quickstart
import (
_ "embed"
"io/ioutil"
"os"
"path/filepath"
"github.com/zeromicro/go-zero/core/logx"
@@ -35,7 +35,7 @@ func initAPIFlags() error {
apiFilename := filepath.Join(apiWorkDir, "greet.api")
apiBytes := []byte(apiContent)
if err := ioutil.WriteFile(apiFilename, apiBytes, 0o666); err != nil {
if err := os.WriteFile(apiFilename, apiBytes, 0o666); err != nil {
return err
}
@@ -59,7 +59,7 @@ func (m mono) createAPIProject() {
log.Debug(">> Generating quickstart api project...")
logx.Must(gogen.GoCommand(nil, nil))
etcFile := filepath.Join(apiWorkDir, "etc", "greet.yaml")
logx.Must(ioutil.WriteFile(etcFile, []byte(apiEtcContent), 0o666))
logx.Must(os.WriteFile(etcFile, []byte(apiEtcContent), 0o666))
logicFile := filepath.Join(apiWorkDir, "internal", "logic", "pinglogic.go")
svcFile := filepath.Join(apiWorkDir, "internal", "svc", "servicecontext.go")
configPath := filepath.Join(apiWorkDir, "internal", "config")