1
0
mirror of https://github.com/pocketbase/pocketbase.git synced 2025-11-25 15:42:01 +02:00
Files
pocketbase/tools/osutils/run.go
2025-09-06 21:45:04 +03:00

33 lines
488 B
Go

package osutils
import (
"os"
"strings"
)
var runDirs = []string{os.TempDir(), cacheDir()}
// IsProbablyGoRun loosely checks if the current program was started with "go run".
func IsProbablyGoRun() bool {
for _, dir := range runDirs {
if dir != "" && strings.HasPrefix(os.Args[0], dir) {
return true
}
}
return false
}
func cacheDir() string {
dir := os.Getenv("GOCACHE")
if dir == "off" {
return ""
}
if dir == "" {
dir, _ = os.UserCacheDir()
}
return dir
}