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,6 @@ package test
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"testing"
@@ -120,7 +119,7 @@ func TestApiParser(t *testing.T) {
t.Run("nestedImport", func(t *testing.T) {
file := filepath.Join(pathx.MustTempDir(), "foo.api")
err := ioutil.WriteFile(file, []byte(nestedAPIImport), os.ModePerm)
err := os.WriteFile(file, []byte(nestedAPIImport), os.ModePerm)
if err != nil {
return
}
@@ -150,7 +149,7 @@ func TestApiParser(t *testing.T) {
t.Run("ambiguousSyntax", func(t *testing.T) {
file := filepath.Join(pathx.MustTempDir(), "foo.api")
err := ioutil.WriteFile(file, []byte(ambiguousSyntax), os.ModePerm)
err := os.WriteFile(file, []byte(ambiguousSyntax), os.ModePerm)
if err != nil {
return
}
@@ -164,7 +163,7 @@ func TestApiParser(t *testing.T) {
t.Run("ambiguousSyntax", func(t *testing.T) {
file := filepath.Join(pathx.MustTempDir(), "foo.api")
err := ioutil.WriteFile(file, []byte(ambiguousSyntax), os.ModePerm)
err := os.WriteFile(file, []byte(ambiguousSyntax), os.ModePerm)
if err != nil {
return
}
@@ -178,7 +177,7 @@ func TestApiParser(t *testing.T) {
t.Run("ambiguousService", func(t *testing.T) {
file := filepath.Join(pathx.MustTempDir(), "foo.api")
err := ioutil.WriteFile(file, []byte(ambiguousService), os.ModePerm)
err := os.WriteFile(file, []byte(ambiguousService), os.ModePerm)
if err != nil {
return
}
@@ -208,7 +207,7 @@ func TestApiParser(t *testing.T) {
assert.Error(t, err)
file := filepath.Join(pathx.MustTempDir(), "foo.api")
err = ioutil.WriteFile(file, []byte(duplicateHandler), os.ModePerm)
err = os.WriteFile(file, []byte(duplicateHandler), os.ModePerm)
if err != nil {
return
}
@@ -237,7 +236,7 @@ func TestApiParser(t *testing.T) {
assert.Error(t, err)
file := filepath.Join(pathx.MustTempDir(), "foo.api")
err = ioutil.WriteFile(file, []byte(duplicateRoute), os.ModePerm)
err = os.WriteFile(file, []byte(duplicateRoute), os.ModePerm)
if err != nil {
return
}
@@ -261,7 +260,7 @@ func TestApiParser(t *testing.T) {
assert.Error(t, err)
file := filepath.Join(pathx.MustTempDir(), "foo.api")
err = ioutil.WriteFile(file, []byte(duplicateType), os.ModePerm)
err = os.WriteFile(file, []byte(duplicateType), os.ModePerm)
if err != nil {
return
}