aboutsummaryrefslogtreecommitdiff
path: root/src/os
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2020-07-07 13:49:21 -0400
committerRuss Cox <rsc@golang.org>2020-10-20 02:32:42 +0000
commit7bb721b9384bdd196befeaed593b185f7f2a5589 (patch)
tree882f21fc2e1fbba6fb11100e4fd8efc5f973a44d /src/os
parentd4da735091986868015369e01c63794af9cc9b84 (diff)
downloadgo-7bb721b9384bdd196befeaed593b185f7f2a5589.tar.xz
all: update references to symbols moved from os to io/fs
The old os references are still valid, but update our code to reflect best practices and get used to the new locations. Code compiled with the bootstrap toolchain (cmd/asm, cmd/dist, cmd/compile, debug/elf) must remain Go 1.4-compatible and is excluded. For #41190. Change-Id: I8f9526977867c10a221e2f392f78d7dec073f1bd Reviewed-on: https://go-review.googlesource.com/c/go/+/243907 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
Diffstat (limited to 'src/os')
-rw-r--r--src/os/error_test.go55
-rw-r--r--src/os/error_unix_test.go11
-rw-r--r--src/os/error_windows_test.go11
-rw-r--r--src/os/example_test.go5
-rw-r--r--src/os/exec/exec_plan9.go4
-rw-r--r--src/os/exec/exec_unix.go4
-rw-r--r--src/os/exec/exec_windows.go4
-rw-r--r--src/os/exec/lp_plan9.go3
-rw-r--r--src/os/exec/lp_unix.go3
-rw-r--r--src/os/exec/lp_windows.go5
-rw-r--r--src/os/os_test.go2
-rw-r--r--src/os/os_windows_test.go11
-rw-r--r--src/os/pipe_test.go17
-rw-r--r--src/os/removeall_test.go2
-rw-r--r--src/os/signal/signal_cgo_test.go3
-rw-r--r--src/os/stat_test.go19
16 files changed, 85 insertions, 74 deletions
diff --git a/src/os/error_test.go b/src/os/error_test.go
index 3d921578fd..060cf59875 100644
--- a/src/os/error_test.go
+++ b/src/os/error_test.go
@@ -7,6 +7,7 @@ package os_test
import (
"errors"
"fmt"
+ "io/fs"
"io/ioutil"
"os"
"path/filepath"
@@ -27,7 +28,7 @@ func TestErrIsExist(t *testing.T) {
t.Fatal("Open should have failed")
return
}
- if s := checkErrorPredicate("os.IsExist", os.IsExist, err, os.ErrExist); s != "" {
+ if s := checkErrorPredicate("os.IsExist", os.IsExist, err, fs.ErrExist); s != "" {
t.Fatal(s)
return
}
@@ -39,7 +40,7 @@ func testErrNotExist(name string) string {
f.Close()
return "Open should have failed"
}
- if s := checkErrorPredicate("os.IsNotExist", os.IsNotExist, err, os.ErrNotExist); s != "" {
+ if s := checkErrorPredicate("os.IsNotExist", os.IsNotExist, err, fs.ErrNotExist); s != "" {
return s
}
@@ -47,7 +48,7 @@ func testErrNotExist(name string) string {
if err == nil {
return "Chdir should have failed"
}
- if s := checkErrorPredicate("os.IsNotExist", os.IsNotExist, err, os.ErrNotExist); s != "" {
+ if s := checkErrorPredicate("os.IsNotExist", os.IsNotExist, err, fs.ErrNotExist); s != "" {
return s
}
return ""
@@ -91,18 +92,18 @@ type isExistTest struct {
}
var isExistTests = []isExistTest{
- {&os.PathError{Err: os.ErrInvalid}, false, false},
- {&os.PathError{Err: os.ErrPermission}, false, false},
- {&os.PathError{Err: os.ErrExist}, true, false},
- {&os.PathError{Err: os.ErrNotExist}, false, true},
- {&os.PathError{Err: os.ErrClosed}, false, false},
- {&os.LinkError{Err: os.ErrInvalid}, false, false},
- {&os.LinkError{Err: os.ErrPermission}, false, false},
- {&os.LinkError{Err: os.ErrExist}, true, false},
- {&os.LinkError{Err: os.ErrNotExist}, false, true},
- {&os.LinkError{Err: os.ErrClosed}, false, false},
- {&os.SyscallError{Err: os.ErrNotExist}, false, true},
- {&os.SyscallError{Err: os.ErrExist}, true, false},
+ {&fs.PathError{Err: fs.ErrInvalid}, false, false},
+ {&fs.PathError{Err: fs.ErrPermission}, false, false},
+ {&fs.PathError{Err: fs.ErrExist}, true, false},
+ {&fs.PathError{Err: fs.ErrNotExist}, false, true},
+ {&fs.PathError{Err: fs.ErrClosed}, false, false},
+ {&os.LinkError{Err: fs.ErrInvalid}, false, false},
+ {&os.LinkError{Err: fs.ErrPermission}, false, false},
+ {&os.LinkError{Err: fs.ErrExist}, true, false},
+ {&os.LinkError{Err: fs.ErrNotExist}, false, true},
+ {&os.LinkError{Err: fs.ErrClosed}, false, false},
+ {&os.SyscallError{Err: fs.ErrNotExist}, false, true},
+ {&os.SyscallError{Err: fs.ErrExist}, true, false},
{nil, false, false},
}
@@ -111,14 +112,14 @@ func TestIsExist(t *testing.T) {
if is := os.IsExist(tt.err); is != tt.is {
t.Errorf("os.IsExist(%T %v) = %v, want %v", tt.err, tt.err, is, tt.is)
}
- if is := errors.Is(tt.err, os.ErrExist); is != tt.is {
- t.Errorf("errors.Is(%T %v, os.ErrExist) = %v, want %v", tt.err, tt.err, is, tt.is)
+ if is := errors.Is(tt.err, fs.ErrExist); is != tt.is {
+ t.Errorf("errors.Is(%T %v, fs.ErrExist) = %v, want %v", tt.err, tt.err, is, tt.is)
}
if isnot := os.IsNotExist(tt.err); isnot != tt.isnot {
t.Errorf("os.IsNotExist(%T %v) = %v, want %v", tt.err, tt.err, isnot, tt.isnot)
}
- if isnot := errors.Is(tt.err, os.ErrNotExist); isnot != tt.isnot {
- t.Errorf("errors.Is(%T %v, os.ErrNotExist) = %v, want %v", tt.err, tt.err, isnot, tt.isnot)
+ if isnot := errors.Is(tt.err, fs.ErrNotExist); isnot != tt.isnot {
+ t.Errorf("errors.Is(%T %v, fs.ErrNotExist) = %v, want %v", tt.err, tt.err, isnot, tt.isnot)
}
}
}
@@ -130,8 +131,8 @@ type isPermissionTest struct {
var isPermissionTests = []isPermissionTest{
{nil, false},
- {&os.PathError{Err: os.ErrPermission}, true},
- {&os.SyscallError{Err: os.ErrPermission}, true},
+ {&fs.PathError{Err: fs.ErrPermission}, true},
+ {&os.SyscallError{Err: fs.ErrPermission}, true},
}
func TestIsPermission(t *testing.T) {
@@ -139,8 +140,8 @@ func TestIsPermission(t *testing.T) {
if got := os.IsPermission(tt.err); got != tt.want {
t.Errorf("os.IsPermission(%#v) = %v; want %v", tt.err, got, tt.want)
}
- if got := errors.Is(tt.err, os.ErrPermission); got != tt.want {
- t.Errorf("errors.Is(%#v, os.ErrPermission) = %v; want %v", tt.err, got, tt.want)
+ if got := errors.Is(tt.err, fs.ErrPermission); got != tt.want {
+ t.Errorf("errors.Is(%#v, fs.ErrPermission) = %v; want %v", tt.err, got, tt.want)
}
}
}
@@ -170,8 +171,8 @@ func TestErrPathNUL(t *testing.T) {
}
func TestPathErrorUnwrap(t *testing.T) {
- pe := &os.PathError{Err: os.ErrInvalid}
- if !errors.Is(pe, os.ErrInvalid) {
+ pe := &fs.PathError{Err: fs.ErrInvalid}
+ if !errors.Is(pe, fs.ErrInvalid) {
t.Error("errors.Is failed, wanted success")
}
}
@@ -181,7 +182,7 @@ type myErrorIs struct{ error }
func (e myErrorIs) Is(target error) bool { return target == e.error }
func TestErrorIsMethods(t *testing.T) {
- if os.IsPermission(myErrorIs{os.ErrPermission}) {
- t.Error("os.IsPermission(err) = true when err.Is(os.ErrPermission), wanted false")
+ if os.IsPermission(myErrorIs{fs.ErrPermission}) {
+ t.Error("os.IsPermission(err) = true when err.Is(fs.ErrPermission), wanted false")
}
}
diff --git a/src/os/error_unix_test.go b/src/os/error_unix_test.go
index bfc83c9867..18bcf3f4e4 100644
--- a/src/os/error_unix_test.go
+++ b/src/os/error_unix_test.go
@@ -7,14 +7,15 @@
package os_test
import (
+ "io/fs"
"os"
"syscall"
)
func init() {
isExistTests = append(isExistTests,
- isExistTest{err: &os.PathError{Err: syscall.EEXIST}, is: true, isnot: false},
- isExistTest{err: &os.PathError{Err: syscall.ENOTEMPTY}, is: true, isnot: false},
+ isExistTest{err: &fs.PathError{Err: syscall.EEXIST}, is: true, isnot: false},
+ isExistTest{err: &fs.PathError{Err: syscall.ENOTEMPTY}, is: true, isnot: false},
isExistTest{err: &os.LinkError{Err: syscall.EEXIST}, is: true, isnot: false},
isExistTest{err: &os.LinkError{Err: syscall.ENOTEMPTY}, is: true, isnot: false},
@@ -23,9 +24,9 @@ func init() {
isExistTest{err: &os.SyscallError{Err: syscall.ENOTEMPTY}, is: true, isnot: false},
)
isPermissionTests = append(isPermissionTests,
- isPermissionTest{err: &os.PathError{Err: syscall.EACCES}, want: true},
- isPermissionTest{err: &os.PathError{Err: syscall.EPERM}, want: true},
- isPermissionTest{err: &os.PathError{Err: syscall.EEXIST}, want: false},
+ isPermissionTest{err: &fs.PathError{Err: syscall.EACCES}, want: true},
+ isPermissionTest{err: &fs.PathError{Err: syscall.EPERM}, want: true},
+ isPermissionTest{err: &fs.PathError{Err: syscall.EEXIST}, want: false},
isPermissionTest{err: &os.LinkError{Err: syscall.EACCES}, want: true},
isPermissionTest{err: &os.LinkError{Err: syscall.EPERM}, want: true},
diff --git a/src/os/error_windows_test.go b/src/os/error_windows_test.go
index 1635c1088e..b8191c5ebc 100644
--- a/src/os/error_windows_test.go
+++ b/src/os/error_windows_test.go
@@ -7,6 +7,7 @@
package os_test
import (
+ "io/fs"
"os"
"syscall"
)
@@ -15,24 +16,24 @@ func init() {
const _ERROR_BAD_NETPATH = syscall.Errno(53)
isExistTests = append(isExistTests,
- isExistTest{err: &os.PathError{Err: syscall.ERROR_FILE_NOT_FOUND}, is: false, isnot: true},
+ isExistTest{err: &fs.PathError{Err: syscall.ERROR_FILE_NOT_FOUND}, is: false, isnot: true},
isExistTest{err: &os.LinkError{Err: syscall.ERROR_FILE_NOT_FOUND}, is: false, isnot: true},
isExistTest{err: &os.SyscallError{Err: syscall.ERROR_FILE_NOT_FOUND}, is: false, isnot: true},
- isExistTest{err: &os.PathError{Err: _ERROR_BAD_NETPATH}, is: false, isnot: true},
+ isExistTest{err: &fs.PathError{Err: _ERROR_BAD_NETPATH}, is: false, isnot: true},
isExistTest{err: &os.LinkError{Err: _ERROR_BAD_NETPATH}, is: false, isnot: true},
isExistTest{err: &os.SyscallError{Err: _ERROR_BAD_NETPATH}, is: false, isnot: true},
- isExistTest{err: &os.PathError{Err: syscall.ERROR_PATH_NOT_FOUND}, is: false, isnot: true},
+ isExistTest{err: &fs.PathError{Err: syscall.ERROR_PATH_NOT_FOUND}, is: false, isnot: true},
isExistTest{err: &os.LinkError{Err: syscall.ERROR_PATH_NOT_FOUND}, is: false, isnot: true},
isExistTest{err: &os.SyscallError{Err: syscall.ERROR_PATH_NOT_FOUND}, is: false, isnot: true},
- isExistTest{err: &os.PathError{Err: syscall.ERROR_DIR_NOT_EMPTY}, is: true, isnot: false},
+ isExistTest{err: &fs.PathError{Err: syscall.ERROR_DIR_NOT_EMPTY}, is: true, isnot: false},
isExistTest{err: &os.LinkError{Err: syscall.ERROR_DIR_NOT_EMPTY}, is: true, isnot: false},
isExistTest{err: &os.SyscallError{Err: syscall.ERROR_DIR_NOT_EMPTY}, is: true, isnot: false},
)
isPermissionTests = append(isPermissionTests,
- isPermissionTest{err: &os.PathError{Err: syscall.ERROR_ACCESS_DENIED}, want: true},
+ isPermissionTest{err: &fs.PathError{Err: syscall.ERROR_ACCESS_DENIED}, want: true},
isPermissionTest{err: &os.LinkError{Err: syscall.ERROR_ACCESS_DENIED}, want: true},
isPermissionTest{err: &os.SyscallError{Err: syscall.ERROR_ACCESS_DENIED}, want: true},
)
diff --git a/src/os/example_test.go b/src/os/example_test.go
index 822886f70c..fbb277b6f1 100644
--- a/src/os/example_test.go
+++ b/src/os/example_test.go
@@ -6,6 +6,7 @@ package os_test
import (
"fmt"
+ "io/fs"
"log"
"os"
"time"
@@ -62,9 +63,9 @@ func ExampleFileMode() {
fmt.Println("regular file")
case mode.IsDir():
fmt.Println("directory")
- case mode&os.ModeSymlink != 0:
+ case mode&fs.ModeSymlink != 0:
fmt.Println("symbolic link")
- case mode&os.ModeNamedPipe != 0:
+ case mode&fs.ModeNamedPipe != 0:
fmt.Println("named pipe")
}
}
diff --git a/src/os/exec/exec_plan9.go b/src/os/exec/exec_plan9.go
index d90bd04399..21ac7b765f 100644
--- a/src/os/exec/exec_plan9.go
+++ b/src/os/exec/exec_plan9.go
@@ -4,14 +4,14 @@
package exec
-import "os"
+import "io/fs"
func init() {
skipStdinCopyError = func(err error) bool {
// Ignore hungup errors copying to stdin if the program
// completed successfully otherwise.
// See Issue 35753.
- pe, ok := err.(*os.PathError)
+ pe, ok := err.(*fs.PathError)
return ok &&
pe.Op == "write" && pe.Path == "|1" &&
pe.Err.Error() == "i/o on hungup channel"
diff --git a/src/os/exec/exec_unix.go b/src/os/exec/exec_unix.go
index 9c3e17d23a..51c52427c2 100644
--- a/src/os/exec/exec_unix.go
+++ b/src/os/exec/exec_unix.go
@@ -7,7 +7,7 @@
package exec
import (
- "os"
+ "io/fs"
"syscall"
)
@@ -16,7 +16,7 @@ func init() {
// Ignore EPIPE errors copying to stdin if the program
// completed successfully otherwise.
// See Issue 9173.
- pe, ok := err.(*os.PathError)
+ pe, ok := err.(*fs.PathError)
return ok &&
pe.Op == "write" && pe.Path == "|1" &&
pe.Err == syscall.EPIPE
diff --git a/src/os/exec/exec_windows.go b/src/os/exec/exec_windows.go
index af8cd97218..bb937f8aed 100644
--- a/src/os/exec/exec_windows.go
+++ b/src/os/exec/exec_windows.go
@@ -5,7 +5,7 @@
package exec
import (
- "os"
+ "io/fs"
"syscall"
)
@@ -15,7 +15,7 @@ func init() {
// to stdin if the program completed successfully otherwise.
// See Issue 20445.
const _ERROR_NO_DATA = syscall.Errno(0xe8)
- pe, ok := err.(*os.PathError)
+ pe, ok := err.(*fs.PathError)
return ok &&
pe.Op == "write" && pe.Path == "|1" &&
(pe.Err == syscall.ERROR_BROKEN_PIPE || pe.Err == _ERROR_NO_DATA)
diff --git a/src/os/exec/lp_plan9.go b/src/os/exec/lp_plan9.go
index 5860cbca4d..e8826a5083 100644
--- a/src/os/exec/lp_plan9.go
+++ b/src/os/exec/lp_plan9.go
@@ -6,6 +6,7 @@ package exec
import (
"errors"
+ "io/fs"
"os"
"path/filepath"
"strings"
@@ -22,7 +23,7 @@ func findExecutable(file string) error {
if m := d.Mode(); !m.IsDir() && m&0111 != 0 {
return nil
}
- return os.ErrPermission
+ return fs.ErrPermission
}
// LookPath searches for an executable named file in the
diff --git a/src/os/exec/lp_unix.go b/src/os/exec/lp_unix.go
index 93793e0eee..66c1df76fb 100644
--- a/src/os/exec/lp_unix.go
+++ b/src/os/exec/lp_unix.go
@@ -8,6 +8,7 @@ package exec
import (
"errors"
+ "io/fs"
"os"
"path/filepath"
"strings"
@@ -24,7 +25,7 @@ func findExecutable(file string) error {
if m := d.Mode(); !m.IsDir() && m&0111 != 0 {
return nil
}
- return os.ErrPermission
+ return fs.ErrPermission
}
// LookPath searches for an executable named file in the
diff --git a/src/os/exec/lp_windows.go b/src/os/exec/lp_windows.go
index 9ea3d76575..e7a2cdf142 100644
--- a/src/os/exec/lp_windows.go
+++ b/src/os/exec/lp_windows.go
@@ -6,6 +6,7 @@ package exec
import (
"errors"
+ "io/fs"
"os"
"path/filepath"
"strings"
@@ -20,7 +21,7 @@ func chkStat(file string) error {
return err
}
if d.IsDir() {
- return os.ErrPermission
+ return fs.ErrPermission
}
return nil
}
@@ -47,7 +48,7 @@ func findExecutable(file string, exts []string) (string, error) {
return f, nil
}
}
- return "", os.ErrNotExist
+ return "", fs.ErrNotExist
}
// LookPath searches for an executable named file in the
diff --git a/src/os/os_test.go b/src/os/os_test.go
index c692ba099f..8f14263401 100644
--- a/src/os/os_test.go
+++ b/src/os/os_test.go
@@ -2526,7 +2526,7 @@ func testDoubleCloseError(t *testing.T, path string) {
if err := file.Close(); err == nil {
t.Error("second Close did not fail")
} else if pe, ok := err.(*PathError); !ok {
- t.Errorf("second Close returned unexpected error type %T; expected os.PathError", pe)
+ t.Errorf("second Close returned unexpected error type %T; expected fs.PathError", pe)
} else if pe.Err != ErrClosed {
t.Errorf("second Close returned %q, wanted %q", err, ErrClosed)
} else {
diff --git a/src/os/os_windows_test.go b/src/os/os_windows_test.go
index f03ec750d0..e002774844 100644
--- a/src/os/os_windows_test.go
+++ b/src/os/os_windows_test.go
@@ -12,6 +12,7 @@ import (
"internal/syscall/windows/registry"
"internal/testenv"
"io"
+ "io/fs"
"io/ioutil"
"os"
osexec "os/exec"
@@ -164,11 +165,11 @@ func testDirLinks(t *testing.T, tests []dirLinkTest) {
t.Errorf("failed to lstat link %v: %v", link, err)
continue
}
- if m := fi2.Mode(); m&os.ModeSymlink == 0 {
+ if m := fi2.Mode(); m&fs.ModeSymlink == 0 {
t.Errorf("%q should be a link, but is not (mode=0x%x)", link, uint32(m))
continue
}
- if m := fi2.Mode(); m&os.ModeDir != 0 {
+ if m := fi2.Mode(); m&fs.ModeDir != 0 {
t.Errorf("%q should be a link, not a directory (mode=0x%x)", link, uint32(m))
continue
}
@@ -681,7 +682,7 @@ func TestStatSymlinkLoop(t *testing.T) {
defer os.Remove("x")
_, err = os.Stat("x")
- if _, ok := err.(*os.PathError); !ok {
+ if _, ok := err.(*fs.PathError); !ok {
t.Errorf("expected *PathError, got %T: %v\n", err, err)
}
}
@@ -1291,9 +1292,9 @@ func TestWindowsReadlink(t *testing.T) {
// os.Mkdir(os.DevNull) fails.
func TestMkdirDevNull(t *testing.T) {
err := os.Mkdir(os.DevNull, 777)
- oserr, ok := err.(*os.PathError)
+ oserr, ok := err.(*fs.PathError)
if !ok {
- t.Fatalf("error (%T) is not *os.PathError", err)
+ t.Fatalf("error (%T) is not *fs.PathError", err)
}
errno, ok := oserr.Err.(syscall.Errno)
if !ok {
diff --git a/src/os/pipe_test.go b/src/os/pipe_test.go
index 429bd813c2..0593efec75 100644
--- a/src/os/pipe_test.go
+++ b/src/os/pipe_test.go
@@ -13,6 +13,7 @@ import (
"fmt"
"internal/testenv"
"io"
+ "io/fs"
"io/ioutil"
"os"
osexec "os/exec"
@@ -46,7 +47,7 @@ func TestEPIPE(t *testing.T) {
if err == nil {
t.Fatal("unexpected success of Write to broken pipe")
}
- if pe, ok := err.(*os.PathError); ok {
+ if pe, ok := err.(*fs.PathError); ok {
err = pe.Err
}
if se, ok := err.(*os.SyscallError); ok {
@@ -202,10 +203,10 @@ func testClosedPipeRace(t *testing.T, read bool) {
}
if err == nil {
t.Error("I/O on closed pipe unexpectedly succeeded")
- } else if pe, ok := err.(*os.PathError); !ok {
- t.Errorf("I/O on closed pipe returned unexpected error type %T; expected os.PathError", pe)
- } else if pe.Err != os.ErrClosed {
- t.Errorf("got error %q but expected %q", pe.Err, os.ErrClosed)
+ } else if pe, ok := err.(*fs.PathError); !ok {
+ t.Errorf("I/O on closed pipe returned unexpected error type %T; expected fs.PathError", pe)
+ } else if pe.Err != fs.ErrClosed {
+ t.Errorf("got error %q but expected %q", pe.Err, fs.ErrClosed)
} else {
t.Logf("I/O returned expected error %q", err)
}
@@ -233,7 +234,7 @@ func TestReadNonblockingFd(t *testing.T) {
defer syscall.SetNonblock(fd, false)
_, err := os.Stdin.Read(make([]byte, 1))
if err != nil {
- if perr, ok := err.(*os.PathError); !ok || perr.Err != syscall.EAGAIN {
+ if perr, ok := err.(*fs.PathError); !ok || perr.Err != syscall.EAGAIN {
t.Fatalf("read on nonblocking stdin got %q, should have gotten EAGAIN", err)
}
}
@@ -308,10 +309,10 @@ func testCloseWithBlockingRead(t *testing.T, r, w *os.File) {
if err == nil {
t.Error("I/O on closed pipe unexpectedly succeeded")
}
- if pe, ok := err.(*os.PathError); ok {
+ if pe, ok := err.(*fs.PathError); ok {
err = pe.Err
}
- if err != io.EOF && err != os.ErrClosed {
+ if err != io.EOF && err != fs.ErrClosed {
t.Errorf("got %v, expected EOF or closed", err)
}
}(c2)
diff --git a/src/os/removeall_test.go b/src/os/removeall_test.go
index 1e5c650fe1..bc9c468ce3 100644
--- a/src/os/removeall_test.go
+++ b/src/os/removeall_test.go
@@ -359,7 +359,7 @@ func TestRemoveAllButReadOnlyAndPathError(t *testing.T) {
t.Errorf("got %q, expected pathErr.path %q", g, w)
}
} else {
- t.Errorf("got %T, expected *os.PathError", err)
+ t.Errorf("got %T, expected *fs.PathError", err)
}
for _, dir := range dirs {
diff --git a/src/os/signal/signal_cgo_test.go b/src/os/signal/signal_cgo_test.go
index a117221400..a8a485613f 100644
--- a/src/os/signal/signal_cgo_test.go
+++ b/src/os/signal/signal_cgo_test.go
@@ -17,6 +17,7 @@ import (
"context"
"fmt"
"io"
+ "io/fs"
"os"
"os/exec"
ptypkg "os/signal/internal/pty"
@@ -127,7 +128,7 @@ func TestTerminalSignal(t *testing.T) {
if len(line) > 0 || len(handled) > 0 {
t.Logf("%q", append(handled, line...))
}
- if perr, ok := err.(*os.PathError); ok {
+ if perr, ok := err.(*fs.PathError); ok {
err = perr.Err
}
// EOF means pty is closed.
diff --git a/src/os/stat_test.go b/src/os/stat_test.go
index 60f3b4c587..88b789080e 100644
--- a/src/os/stat_test.go
+++ b/src/os/stat_test.go
@@ -6,6 +6,7 @@ package os_test
import (
"internal/testenv"
+ "io/fs"
"io/ioutil"
"os"
"path/filepath"
@@ -14,7 +15,7 @@ import (
)
// testStatAndLstat verifies that all os.Stat, os.Lstat os.File.Stat and os.Readdir work.
-func testStatAndLstat(t *testing.T, path string, isLink bool, statCheck, lstatCheck func(*testing.T, string, os.FileInfo)) {
+func testStatAndLstat(t *testing.T, path string, isLink bool, statCheck, lstatCheck func(*testing.T, string, fs.FileInfo)) {
// test os.Stat
sfi, err := os.Stat(path)
if err != nil {
@@ -70,7 +71,7 @@ func testStatAndLstat(t *testing.T, path string, isLink bool, statCheck, lstatCh
}
}
- // test os.FileInfo returned by os.Readdir
+ // test fs.FileInfo returned by os.Readdir
if len(path) > 0 && os.IsPathSeparator(path[len(path)-1]) {
// skip os.Readdir test of directories with slash at the end
return
@@ -88,7 +89,7 @@ func testStatAndLstat(t *testing.T, path string, isLink bool, statCheck, lstatCh
t.Error(err)
return
}
- var lsfi2 os.FileInfo
+ var lsfi2 fs.FileInfo
base := filepath.Base(path)
for _, fi2 := range fis {
if fi2.Name() == base {
@@ -108,34 +109,34 @@ func testStatAndLstat(t *testing.T, path string, isLink bool, statCheck, lstatCh
}
// testIsDir verifies that fi refers to directory.
-func testIsDir(t *testing.T, path string, fi os.FileInfo) {
+func testIsDir(t *testing.T, path string, fi fs.FileInfo) {
t.Helper()
if !fi.IsDir() {
t.Errorf("%q should be a directory", path)
}
- if fi.Mode()&os.ModeSymlink != 0 {
+ if fi.Mode()&fs.ModeSymlink != 0 {
t.Errorf("%q should not be a symlink", path)
}
}
// testIsSymlink verifies that fi refers to symlink.
-func testIsSymlink(t *testing.T, path string, fi os.FileInfo) {
+func testIsSymlink(t *testing.T, path string, fi fs.FileInfo) {
t.Helper()
if fi.IsDir() {
t.Errorf("%q should not be a directory", path)
}
- if fi.Mode()&os.ModeSymlink == 0 {
+ if fi.Mode()&fs.ModeSymlink == 0 {
t.Errorf("%q should be a symlink", path)
}
}
// testIsFile verifies that fi refers to file.
-func testIsFile(t *testing.T, path string, fi os.FileInfo) {
+func testIsFile(t *testing.T, path string, fi fs.FileInfo) {
t.Helper()
if fi.IsDir() {
t.Errorf("%q should not be a directory", path)
}
- if fi.Mode()&os.ModeSymlink != 0 {
+ if fi.Mode()&fs.ModeSymlink != 0 {
t.Errorf("%q should not be a symlink", path)
}
}