1 [!windows] [short] stop 'this test only applies to Windows'
2 env GO111MODULE=off
3
4 go build run_go.go
5 exec ./run_go$GOEXE $GOPATH $GOPATH/src/vend/hello
6 stdout 'hello, world'
7
8 -- run_go.go --
9 package main
10
11 import (
12 "fmt"
13 "os"
14 "os/exec"
15 "path/filepath"
16 "strings"
17 )
18
19 func changeVolume(s string, f func(s string) string) string {
20 vol := filepath.VolumeName(s)
21 return f(vol) + s[len(vol):]
22 }
23
24 func main() {
25 gopath := changeVolume(os.Args[1], strings.ToLower)
26 dir := changeVolume(os.Args[2], strings.ToUpper)
27 cmd := exec.Command("go", "run", "hello.go")
28 cmd.Dir = dir
29 cmd.Env = append(os.Environ(), "GOPATH="+gopath)
30 cmd.Stdout = os.Stdout
31 cmd.Stderr = os.Stderr
32 if err := cmd.Run(); err != nil {
33 fmt.Fprintln(os.Stderr, err)
34 os.Exit(1)
35 }
36 }
37
38 -- vend/hello/hello.go --
39 package main
40
41 import (
42 "fmt"
43 "strings" // really ../vendor/strings
44 )
45
46 func main() {
47 fmt.Printf("%s\n", strings.Msg)
48 }
49 -- vend/vendor/strings/msg.go --
50 package strings
51
52 var Msg = "hello, world"
53
View as plain text