1
2
3
4
5 package base
6
7 import (
8 "cmd/go/internal/cfg"
9 "fmt"
10 "os"
11 "path/filepath"
12 "runtime"
13 )
14
15
16
17
18
19
20 func AppendPWD(base []string, dir string) []string {
21
22
23 if !filepath.IsAbs(dir) {
24 panic(fmt.Sprintf("AppendPWD with relative path %q", dir))
25 }
26 return append(base, "PWD="+dir)
27 }
28
29
30
31 func AppendPATH(base []string) []string {
32 if cfg.GOROOTbin == "" {
33 return base
34 }
35
36 pathVar := "PATH"
37 if runtime.GOOS == "plan9" {
38 pathVar = "path"
39 }
40
41 path := os.Getenv(pathVar)
42 if path == "" {
43 return append(base, pathVar+"="+cfg.GOROOTbin)
44 }
45 return append(base, pathVar+"="+cfg.GOROOTbin+string(os.PathListSeparator)+path)
46 }
47
View as plain text