summaryrefslogtreecommitdiff
path: root/src/pkg/os/env_unix.go
diff options
context:
space:
mode:
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
+}