// Package runtimeassets locates tools shipped alongside the application. package runtimeassets import ( "os" "path/filepath" ) // Candidates keeps installed resources ahead of the development checkout. // Installed applications never depend on the caller's working directory. func Candidates(relative string) []string { exe, _ := os.Executable() if resolved, err := filepath.EvalSymlinks(exe); err == nil { exe = resolved } cwd, _ := os.Getwd() return candidates(filepath.Dir(exe), cwd, relative) } func candidates(exeDir, cwd, relative string) []string { return []string{ filepath.Join(exeDir, relative), filepath.Join(exeDir, "..", "Resources", relative), filepath.Join(cwd, "third_party", relative), filepath.Join(cwd, "..", "third_party", relative), } } func Find(relative string) string { for _, p := range Candidates(relative) { if st, err := os.Stat(p); err == nil && !st.IsDir() { absolute, _ := filepath.Abs(p) return absolute } } return "" }