Skip to content

Commit

Permalink
os: handle TMPDIR in TempDir on Plan 9
Browse files Browse the repository at this point in the history
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 golang#27065.

Change-Id: Id6ff926c5c379f63cab2dfc378fa6c15293fd453
Reviewed-on: https://go-review.googlesource.com/129775
Reviewed-by: Brad Fitzpatrick <[email protected]>
  • Loading branch information
0intro authored and bradfitz committed Aug 17, 2018
1 parent 64fae25 commit 0a842d5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/os/file_plan9.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 0a842d5

Please sign in to comment.