🎨 user cache dir

This commit is contained in:
Liang Ding 2019-05-16 12:41:39 +08:00
parent 07e9f4654f
commit be2d5b74b3
No known key found for this signature in database
GPG Key ID: 136F30F901A2231D
1 changed files with 6 additions and 0 deletions

View File

@ -106,12 +106,18 @@ func parsePath(curDir, outputLine string) string {
func setCmdEnv(cmd *exec.Cmd, username string) {
userWorkspace := conf.GetUserWorkspace(username)
cache, err := os.UserCacheDir()
if nil != err {
logger.Warnf("Get user cache dir failed [" + err.Error() + "]")
cache = os.TempDir()
}
cmd.Env = append(cmd.Env,
"GOPATH="+userWorkspace,
"GOOS="+runtime.GOOS,
"GOARCH="+runtime.GOARCH,
"GOROOT="+runtime.GOROOT(),
"GOCACHE="+cache,
"PATH="+os.Getenv("PATH"))
if util.OS.IsWindows() {