1 # Install an env command because Windows and plan9 don't have it.
2 env GOBIN=$WORK/tmp/bin
3 go install env.go
4 [plan9] env path=$GOBIN${:}$path
5 [!plan9] env PATH=$GOBIN${:}$PATH
6
7 # Test generators have access to the environment
8 go generate ./printenv.go
9 stdout '^GOARCH='$GOARCH
10 stdout '^GOOS='$GOOS
11 stdout '^GOFILE='
12 stdout '^GOLINE='
13 stdout '^GOPACKAGE='
14 stdout '^DOLLAR='
15
16 -- env.go --
17 package main
18
19 import (
20 "fmt"
21 "os"
22 )
23
24 func main() {
25 for _, v := range os.Environ() {
26 fmt.Println(v)
27 }
28 }
29 -- printenv.go --
30 package main
31
32 //go:generate env
View as plain text