...

Text file src/cmd/go/testdata/script/generate_env.txt

Documentation: cmd/go/testdata/script

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

View as plain text