File tree 2 files changed +46
-1
lines changed
2 files changed +46
-1
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import (
14
14
"os"
15
15
"os/exec"
16
16
"reflect"
17
+ "slices"
17
18
"strings"
18
19
"sync"
19
20
@@ -211,7 +212,9 @@ func RunStdin(cmdline []string) {
211
212
cmd .Stdin = os .Stdin
212
213
cmd .Stdout = os .Stdout
213
214
cmd .Stderr = os .Stderr
214
- cmd .Env = cfg .OrigEnv
215
+ env := slices .Clip (cfg .OrigEnv )
216
+ env = AppendPATH (env )
217
+ cmd .Env = env
215
218
StartSigHandlers ()
216
219
if err := cmd .Run (); err != nil {
217
220
Errorf ("%v" , err )
Original file line number Diff line number Diff line change
1
+ # https://go.dev/issue/68005: 'go run' should run the program with its own GOROOT/bin
2
+ # at the beginning of $PATH.
3
+
4
+ [short] skip
5
+
6
+ [!GOOS:plan9] env PATH=
7
+ [GOOS:plan9] env path=
8
+ go run .
9
+
10
+ [!GOOS:plan9] env PATH=$WORK${/}bin
11
+ [GOOS:plan9] env path=$WORK${/}bin
12
+ go run .
13
+
14
+ -- go.mod --
15
+ module example
16
+
17
+ go 1.19
18
+ -- main.go --
19
+ package main
20
+
21
+ import (
22
+ "fmt"
23
+ "os"
24
+ "os/exec"
25
+ "path/filepath"
26
+ )
27
+
28
+ func main() {
29
+ got, err := exec.LookPath("go")
30
+ if err != nil {
31
+ fmt.Println(err)
32
+ os.Exit(1)
33
+ }
34
+
35
+ want := filepath.Join(os.Getenv("GOROOT"), "bin", "go" + os.Getenv("GOEXE"))
36
+ if got != want {
37
+ fmt.Printf(`exec.LookPath("go") = %q; want %q\n`, got, want)
38
+ os.Exit(1)
39
+ }
40
+ }
41
+ -- $WORK/bin/README.txt --
42
+ This directory contains no executables.
You can’t perform that action at this time.
0 commit comments