aboutsummaryrefslogtreecommitdiffhomepage
path: root/testdata/env.go
blob: 115da6d3d1b27bbdcf9bc96d5795e4f5db498916 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package main

import (
	"os"
)

func main() {
	// Check for environment variables (set by the test runner).
	println("ENV1:", os.Getenv("ENV1"))
	v, ok := os.LookupEnv("ENV2")
	if !ok {
		println("ENV2 not found")
	}
	println("ENV2:", v)

	// Check for command line arguments.
	// Argument 0 is skipped because it is the program name, which varies by
	// test run.
	println()
	for _, arg := range os.Args[1:] {
		println("arg:", arg)
	}
}