package common import ( "os" "path/filepath" ) var rootDirFunc = RuntimeBaseDir func RuntimeBaseDir() string { exe, err := os.Executable() if err == nil { return filepath.Dir(exe) } return "." } func RootDir() string { return rootDirFunc() } func SetRootDirForTest(fn func() string) func() { prev := rootDirFunc rootDirFunc = fn return func() { rootDirFunc = prev } }