summaryrefslogtreecommitdiff
path: root/src/pkg/os/env_unix.go
blob: 0c13bda0e36c9923e077c7b5d0b693f6f4359a3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
}