From: Brad Fitzpatrick Date: Thu, 4 Oct 2018 15:26:04 +0000 (+0000) Subject: os: make UserHomeDir specialize behavior for GOOS=android X-Git-Tag: go1.12beta1~893 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=f22c357a34521404c445dc2e848657ecbfa4ad5e;p=gostls13.git os: make UserHomeDir specialize behavior for GOOS=android Change-Id: I69582662aeee7344226856c24907516ddfc92f60 Reviewed-on: https://go-review.googlesource.com/c/139717 Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot Reviewed-by: Elias Naur --- diff --git a/src/os/file.go b/src/os/file.go index eb2277dece..61f37f2489 100644 --- a/src/os/file.go +++ b/src/os/file.go @@ -387,16 +387,16 @@ func UserCacheDir() (string, error) { // On Windows, it returns the concatenation of %HOMEDRIVE% and %HOMEPATH%. // On Plan 9, it returns the $home environment variable. func UserHomeDir() string { - if runtime.GOOS == "windows" { + switch runtime.GOOS { + case "windows": return Getenv("HOMEDRIVE") + Getenv("HOMEPATH") - } - if runtime.GOOS == "plan9" { + case "plan9": return Getenv("home") - } - if runtime.GOOS == "nacl" { + case "nacl", "android": return "/" + default: + return Getenv("HOME") } - return Getenv("HOME") } // Chmod changes the mode of the named file to mode.