зеркало из https://github.com/golang/tools.git
cmd/stringer: replace ioutil with os
Change-Id: I16c8556a90a775e5e3addb2f5907cba04d9c4bb1
GitHub-Last-Rev: 12dc5e7872
GitHub-Pull-Request: golang/tools#408
Reviewed-on: https://go-review.googlesource.com/c/tools/+/439516
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
This commit is contained in:
Родитель
3c3713e6a5
Коммит
8f3241104a
|
@ -14,7 +14,6 @@ import (
|
|||
"fmt"
|
||||
"go/build"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
|
@ -113,7 +112,7 @@ func TestTags(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
result, err := ioutil.ReadFile(output)
|
||||
result, err := os.ReadFile(output)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -128,7 +127,7 @@ func TestTags(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
result, err = ioutil.ReadFile(output)
|
||||
result, err = os.ReadFile(output)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -184,7 +183,7 @@ func buildStringer(t *testing.T) (dir string, stringer string) {
|
|||
t.Helper()
|
||||
testenv.NeedsTool(t, "go")
|
||||
|
||||
dir, err := ioutil.TempDir("", "stringer")
|
||||
dir, err := os.MkdirTemp("", "stringer")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
@ -452,7 +451,7 @@ func (i Token) String() string {
|
|||
func TestGolden(t *testing.T) {
|
||||
testenv.NeedsTool(t, "go")
|
||||
|
||||
dir, err := ioutil.TempDir("", "stringer")
|
||||
dir, err := os.MkdirTemp("", "stringer")
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
@ -466,7 +465,7 @@ func TestGolden(t *testing.T) {
|
|||
input := "package test\n" + test.input
|
||||
file := test.name + ".go"
|
||||
absFile := filepath.Join(dir, file)
|
||||
err := ioutil.WriteFile(absFile, []byte(input), 0644)
|
||||
err := os.WriteFile(absFile, []byte(input), 0644)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
|
|
@ -76,7 +76,6 @@ import (
|
|||
"go/format"
|
||||
"go/token"
|
||||
"go/types"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
@ -166,7 +165,7 @@ func main() {
|
|||
baseName := fmt.Sprintf("%s_string.go", types[0])
|
||||
outputName = filepath.Join(dir, strings.ToLower(baseName))
|
||||
}
|
||||
err := ioutil.WriteFile(outputName, src, 0644)
|
||||
err := os.WriteFile(outputName, src, 0644)
|
||||
if err != nil {
|
||||
log.Fatalf("writing output: %s", err)
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче