summaryrefslogtreecommitdiff
path: root/src/pkg/os/env_unix.go
diff options
context:
space:
mode:
authorPeter Mundy <go.peter.90@gmail.com>2010-06-30 13:52:34 -0700
committerPeter Mundy <go.peter.90@gmail.com>2010-06-30 13:52:34 -0700
commitd9d5009aac5a61a08fd9e2125321197e4cf55976 (patch)
tree40bfaa22cdd826cbba2eec971e62508d2d4f529d /src/pkg/os/env_unix.go
parentd364bb8ed786ab6c4877f19f0b286ed05894f0b0 (diff)
downloadgolang-d9d5009aac5a61a08fd9e2125321197e4cf55976.tar.gz
io/ioutil.TempFile for Windows
Fixes issue 834. R=rsc, brainman CC=golang-dev http://codereview.appspot.com/1686047 Committer: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/pkg/os/env_unix.go')
-rwxr-xr-xsrc/pkg/os/env_unix.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/pkg/os/env_unix.go b/src/pkg/os/env_unix.go
new file mode 100755
index 000000000..0c13bda0e
--- /dev/null
+++ b/src/pkg/os/env_unix.go
@@ -0,0 +1,19 @@
+// Copyright 2010 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.
+
+// Unix environment variables.
+
+package os
+
+// TempDir returns the default directory to use for temporary files.
+// On Unix-like systems, it uses the environment variable $TMPDIR
+// or, if that is empty, /tmp.
+// On Windows systems, it uses the Windows GetTempPath API.
+func TempDir() string {
+ dir := Getenv("TMPDIR")
+ if dir == "" {
+ dir = "/tmp"
+ }
+ return dir
+}