replace io/ioutil to os (#7281)

This commit is contained in:
Koya IWAMURA
2022-06-15 07:10:57 +09:00
committed by GitHub
parent a18ea40d6a
commit 9fce2fbf2a
2 changed files with 6 additions and 7 deletions

View File

@@ -52,10 +52,10 @@ a `[]byte`, which you pass to the `GetRootAsMonster` function:
example "MyGame/Example"
flatbuffers "github.com/google/flatbuffers/go"
io/ioutil
"os"
)
buf, err := ioutil.ReadFile("monster.dat")
buf, err := os.ReadFile("monster.dat")
// handle err
monster := example.GetRootAsMonster(buf, 0)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@@ -24,7 +24,6 @@ import (
"bytes"
"flag"
"fmt"
"io/ioutil"
"os"
"reflect"
"sort"
@@ -101,7 +100,7 @@ func TestAll(t *testing.T) {
// Verify that the buffer generated by C++ code is readable by the
// generated Go code:
monsterDataCpp, err := ioutil.ReadFile(cppData)
monsterDataCpp, err := os.ReadFile(cppData)
if err != nil {
t.Fatal(err)
}
@@ -141,7 +140,7 @@ func TestAll(t *testing.T) {
// is given, check that Go code can read it, and that Go code
// generates an identical buffer when used to create the example data:
if javaData != "" {
monsterDataJava, err := ioutil.ReadFile(javaData)
monsterDataJava, err := os.ReadFile(javaData)
if err != nil {
t.Fatal(err)
}
@@ -155,7 +154,7 @@ func TestAll(t *testing.T) {
}
// Write the generated buffer out to a file:
err = ioutil.WriteFile(outData, generated[off:], os.FileMode(0644))
err = os.WriteFile(outData, generated[off:], os.FileMode(0644))
if err != nil {
t.Fatal(err)
}
@@ -1685,7 +1684,7 @@ func CheckSizePrefixedBuffer(fail func(string, ...interface{})) {
CheckObjectAPI(generated, off, true, fail)
// Write generated bfufer out to a file
if err := ioutil.WriteFile(outData+".sp", generated[off:], os.FileMode(0644)); err != nil {
if err := os.WriteFile(outData+".sp", generated[off:], os.FileMode(0644)); err != nil {
fail("failed to write file: %s", err)
}
}