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.
43
View as plain text