From d1f173cab39191c0db7e3272b6b57d399735a14f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lilian=20J=C3=B3nsd=C3=B3ttir?= Date: Thu, 14 Mar 2024 09:47:19 -0700 Subject: [PATCH] support for android via termux I have no idea if it's possible (or even worth it) to get go running in the adb shell android has no /tmp so I wouldn't know where to store files outside of termux --- pkg/env/env.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/env/env.go b/pkg/env/env.go index ebebf58..b2c1fc3 100644 --- a/pkg/env/env.go +++ b/pkg/env/env.go @@ -78,16 +78,24 @@ func GetDataDir(appname string) string { // // returns %TEMP% on Windows, /tmp on UNIX-like systems func GetTempDirectory() string { + var tmp string switch runtime.GOOS { case "windows": - return os.Getenv("TEMP") + tmp = os.Getenv("TEMP") + case "android": + if t := os.Getenv("TMPDIR"); t != "" { + tmp = t + } else if t = os.Getenv("PREFIX"); t != "" { + tmp = t + "/tmp" + } default: fallthrough case "darwin": fallthrough case "linux": - return "/tmp" + tmp = "/tmp" } + return tmp } func make_path(paths ...string) string {