cmd/buildlet: restore tmp/gocache dirs after recursive delete of world

Fixes regression from CL 144637 for s390x and arm5 (the only two deployed with that change).

Fixes golang/go#27182

Change-Id: I7a4a92c7c97f3f6c738d757a05b9dfc755547bf0
Reviewed-on: https://go-review.googlesource.com/c/144858
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
diff --git a/cmd/buildlet/buildlet.go b/cmd/buildlet/buildlet.go
index 45b36ad..29d13df 100644
--- a/cmd/buildlet/buildlet.go
+++ b/cmd/buildlet/buildlet.go
@@ -1224,10 +1224,15 @@
 			return
 		}
 	}
-	// If we nuked the work directory, recreate it.
-	if err := os.MkdirAll(*workDir, 0755); err != nil {
-		http.Error(w, err.Error(), http.StatusInternalServerError)
-		return
+	// If we nuked the work directory (or tmp or gocache), recreate them.
+	for _, dir := range []string{*workDir, processTmpDirEnv, processGoCacheEnv} {
+		if dir == "" {
+			continue
+		}
+		if err := os.MkdirAll(dir, 0755); err != nil {
+			http.Error(w, err.Error(), http.StatusInternalServerError)
+			return
+		}
 	}
 }