Russ Cox | 0b477ef | 2012-02-16 23:48:57 -0500 | [diff] [blame] | 1 | // run |
Rob Pike | 4d12c0e | 2008-09-22 17:31:41 -0700 | [diff] [blame] | 2 | |
| 3 | // Copyright 2009 The Go Authors. All rights reserved. |
| 4 | // Use of this source code is governed by a BSD-style |
| 5 | // license that can be found in the LICENSE file. |
| 6 | |
Rob Pike | 83976e3 | 2012-02-19 14:28:53 +1100 | [diff] [blame] | 7 | // Test that the Go environment variables are present and accessible through |
| 8 | // package os and package runtime. |
| 9 | |
Rob Pike | 4d12c0e | 2008-09-22 17:31:41 -0700 | [diff] [blame] | 10 | package main |
| 11 | |
Ian Lance Taylor | e008757 | 2011-03-30 14:24:32 -0700 | [diff] [blame] | 12 | import ( |
| 13 | "os" |
| 14 | "runtime" |
| 15 | ) |
Rob Pike | 4d12c0e | 2008-09-22 17:31:41 -0700 | [diff] [blame] | 16 | |
| 17 | func main() { |
Brad Fitzpatrick | efacb2a | 2012-02-18 21:18:13 -0800 | [diff] [blame] | 18 | ga := os.Getenv("GOARCH") |
Ian Lance Taylor | e008757 | 2011-03-30 14:24:32 -0700 | [diff] [blame] | 19 | if ga != runtime.GOARCH { |
| 20 | print("$GOARCH=", ga, "!= runtime.GOARCH=", runtime.GOARCH, "\n") |
Rob Pike | 4f61fc9 | 2010-09-04 10:36:13 +1000 | [diff] [blame] | 21 | os.Exit(1) |
Rob Pike | 4d12c0e | 2008-09-22 17:31:41 -0700 | [diff] [blame] | 22 | } |
Brad Fitzpatrick | efacb2a | 2012-02-18 21:18:13 -0800 | [diff] [blame] | 23 | xxx := os.Getenv("DOES_NOT_EXIST") |
| 24 | if xxx != "" { |
| 25 | print("$DOES_NOT_EXIST=", xxx, "\n") |
Rob Pike | 4f61fc9 | 2010-09-04 10:36:13 +1000 | [diff] [blame] | 26 | os.Exit(1) |
Rob Pike | 4d12c0e | 2008-09-22 17:31:41 -0700 | [diff] [blame] | 27 | } |
| 28 | } |