diff options
author | David du Colombier <0intro@gmail.com> | 2018-08-18 00:05:46 +0200 |
---|---|---|
committer | Brad Fitzpatrick <bradfitz@golang.org> | 2018-08-17 23:12:06 +0000 |
commit | 0a842d55609f5deb25889f151e49744c4af3ec80 (patch) | |
tree | b4afcbbb82074c9637c7256558ea4483302aecc2 | |
parent | 64fae252868fe6ab97f743cfadcb54cee8ccca02 (diff) | |
download | go-0a842d55609f5deb25889f151e49744c4af3ec80.tar.gz go-0a842d55609f5deb25889f151e49744c4af3ec80.zip |
os: handle TMPDIR in TempDir on Plan 9
CL 129063 added a test in TestScript/mod_enabled,
which was failing on Plan 9.
The test was failing because the Init function
of the cmd/go/internal/modload package was
expecting ModRoot to be part of os.TempDir.
However, ModRoot was set to TMPDIR, while
os.TempDir is returning /tmp on Plan 9.
This change fixes the implementation of
os.TempDir on Plan 9 to handle the TMPDIR
environment variable, similarly to Unix.
Fixes #27065.
Change-Id: Id6ff926c5c379f63cab2dfc378fa6c15293fd453
Reviewed-on: https://go-review.googlesource.com/129775
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
-rw-r--r-- | src/os/file_plan9.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/os/file_plan9.go b/src/os/file_plan9.go index 3a0b774aa2..2c74403434 100644 --- a/src/os/file_plan9.go +++ b/src/os/file_plan9.go @@ -478,7 +478,12 @@ func (f *File) Chown(uid, gid int) error { } func tempDir() string { - return "/tmp" + dir := Getenv("TMPDIR") + if dir == "" { + dir = "/tmp" + } + return dir + } // Chdir changes the current working directory to the file, |