summaryrefslogtreecommitdiff
path: root/src/os/exec
diff options
context:
space:
mode:
Diffstat (limited to 'src/os/exec')
-rw-r--r--src/os/exec/example_test.go3
-rw-r--r--src/os/exec/exec_plan9.go4
-rw-r--r--src/os/exec/exec_test.go8
-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/exec/read3.go4
9 files changed, 22 insertions, 16 deletions
diff --git a/src/os/exec/example_test.go b/src/os/exec/example_test.go
index 62866fa710..a66890be69 100644
--- a/src/os/exec/example_test.go
+++ b/src/os/exec/example_test.go
@@ -10,7 +10,6 @@ import (
"encoding/json"
"fmt"
"io"
- "io/ioutil"
"log"
"os"
"os/exec"
@@ -128,7 +127,7 @@ func ExampleCmd_StderrPipe() {
log.Fatal(err)
}
- slurp, _ := ioutil.ReadAll(stderr)
+ slurp, _ := io.ReadAll(stderr)
fmt.Printf("%s\n", slurp)
if err := cmd.Wait(); err != nil {
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_test.go b/src/os/exec/exec_test.go
index dafbc64a17..cd3d759ebc 100644
--- a/src/os/exec/exec_test.go
+++ b/src/os/exec/exec_test.go
@@ -605,6 +605,10 @@ func TestExtraFiles(t *testing.T) {
testenv.MustHaveExec(t)
testenv.MustHaveGoBuild(t)
+ // This test runs with cgo disabled. External linking needs cgo, so
+ // it doesn't work if external linking is required.
+ testenv.MustInternalLink(t)
+
if runtime.GOOS == "windows" {
t.Skipf("skipping test on %q", runtime.GOOS)
}
@@ -633,7 +637,7 @@ func TestExtraFiles(t *testing.T) {
// cgo), to make sure none of that potential C code leaks fds.
ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}))
// quiet expected TLS handshake error "remote error: bad certificate"
- ts.Config.ErrorLog = log.New(ioutil.Discard, "", 0)
+ ts.Config.ErrorLog = log.New(io.Discard, "", 0)
ts.StartTLS()
defer ts.Close()
_, err = http.Get(ts.URL)
@@ -826,7 +830,7 @@ func TestHelperProcess(*testing.T) {
}
}
case "stdinClose":
- b, err := ioutil.ReadAll(os.Stdin)
+ b, err := io.ReadAll(os.Stdin)
if err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
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/exec/read3.go b/src/os/exec/read3.go
index 25d732a991..8852023e77 100644
--- a/src/os/exec/read3.go
+++ b/src/os/exec/read3.go
@@ -15,7 +15,7 @@ package main
import (
"fmt"
"internal/poll"
- "io/ioutil"
+ "io"
"os"
"os/exec"
"runtime"
@@ -24,7 +24,7 @@ import (
func main() {
fd3 := os.NewFile(3, "fd3")
- bs, err := ioutil.ReadAll(fd3)
+ bs, err := io.ReadAll(fd3)
if err != nil {
fmt.Printf("ReadAll from fd 3: %v\n", err)
os.Exit(1)