mirror of
https://github.com/golang/go
synced 2024-11-26 17:16:54 -07:00
b6c75c5fb1
The test directory driver currently sets the GOOS/GOARCH environment variables if they aren't set. This appears to be in service of a single test, test/env.go, which was introduced in September 2008 along with os.Getenv. It's not entirely clear what that test is even trying to check, since runtime.GOOS isn't necessarily the same as $GOOS. We keep the test around because golang.org/x/tools/go/ssa/interp uses it as a test case, but we simplify the test and eliminate the need for the driver to set GOOS/GOARCH. Change-Id: I5acc0093b557c95d1f0a526d031210256a68222d Reviewed-on: https://go-review.googlesource.com/c/go/+/493601 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Bryan Mills <bcmills@google.com>
32 lines
549 B
Go
32 lines
549 B
Go
// run
|
|
|
|
// Copyright 2009 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// Test that environment variables are accessible through
|
|
// package os.
|
|
|
|
package main
|
|
|
|
import (
|
|
"os"
|
|
"runtime"
|
|
)
|
|
|
|
func main() {
|
|
ga := os.Getenv("PATH")
|
|
if runtime.GOOS == "plan9" {
|
|
ga = os.Getenv("path")
|
|
}
|
|
if ga == "" {
|
|
print("PATH is empty\n")
|
|
os.Exit(1)
|
|
}
|
|
xxx := os.Getenv("DOES_NOT_EXIST")
|
|
if xxx != "" {
|
|
print("$DOES_NOT_EXIST=", xxx, "\n")
|
|
os.Exit(1)
|
|
}
|
|
}
|