aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/gofmt/gofmt.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/gofmt/gofmt.go')
-rw-r--r--src/cmd/gofmt/gofmt.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/cmd/gofmt/gofmt.go b/src/cmd/gofmt/gofmt.go
index 8c56af7559..dba2411eed 100644
--- a/src/cmd/gofmt/gofmt.go
+++ b/src/cmd/gofmt/gofmt.go
@@ -14,6 +14,7 @@ import (
"go/scanner"
"go/token"
"io"
+ "io/fs"
"io/ioutil"
"os"
"path/filepath"
@@ -73,7 +74,7 @@ func initParserMode() {
}
}
-func isGoFile(f os.FileInfo) bool {
+func isGoFile(f fs.FileInfo) bool {
// ignore non-Go files
name := f.Name()
return !f.IsDir() && !strings.HasPrefix(name, ".") && strings.HasSuffix(name, ".go")
@@ -81,7 +82,7 @@ func isGoFile(f os.FileInfo) bool {
// If in == nil, the source is the contents of the file with the given filename.
func processFile(filename string, in io.Reader, out io.Writer, stdin bool) error {
- var perm os.FileMode = 0644
+ var perm fs.FileMode = 0644
if in == nil {
f, err := os.Open(filename)
if err != nil {
@@ -96,7 +97,7 @@ func processFile(filename string, in io.Reader, out io.Writer, stdin bool) error
perm = fi.Mode().Perm()
}
- src, err := ioutil.ReadAll(in)
+ src, err := io.ReadAll(in)
if err != nil {
return err
}
@@ -163,7 +164,7 @@ func processFile(filename string, in io.Reader, out io.Writer, stdin bool) error
return err
}
-func visitFile(path string, f os.FileInfo, err error) error {
+func visitFile(path string, f fs.FileInfo, err error) error {
if err == nil && isGoFile(f) {
err = processFile(path, nil, os.Stdout, false)
}
@@ -275,7 +276,7 @@ const chmodSupported = runtime.GOOS != "windows"
// backupFile writes data to a new file named filename<number> with permissions perm,
// with <number randomly chosen such that the file name is unique. backupFile returns
// the chosen file name.
-func backupFile(filename string, data []byte, perm os.FileMode) (string, error) {
+func backupFile(filename string, data []byte, perm fs.FileMode) (string, error) {
// create backup file
f, err := ioutil.TempFile(filepath.Dir(filename), filepath.Base(filename))
if err != nil {