diff --git a/utils/utils.go b/utils/utils.go index 2ce7bd8..a009b46 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -14,11 +14,17 @@ import ( ) func RepoDir() string { - cacheDir, err := os.UserCacheDir() - if err != nil { - log.Fatalln("gibo can't determine your user cache directory. Please file an issue at https://github.com/simonwhitaker/gibo/issues") + xdgCacheDir := os.Getenv("XDG_CACHE_HOME") + if len(xdgCacheDir) > 0 { + return filepath.Join(xdgCacheDir, "gibo", "gitignore-boilerplates") + } else { + cacheDir, err := os.UserCacheDir() + if err != nil { + log.Fatalln("gibo can't determine your user cache directory. Please file an issue at https://github.com/simonwhitaker/gibo/issues") + + } + return filepath.Join(cacheDir, "gibo", "gitignore-boilerplates") } - return filepath.Join(cacheDir, "gibo") } func cloneRepo(repo string) error { @@ -56,7 +62,7 @@ func pathForBoilerplate(name string) (string, error) { filename := name + ".gitignore" var result string = "" filepath.WalkDir(RepoDir(), func(path string, d fs.DirEntry, err error) error { - if strings.ToLower(filepath.Base(path)) == strings.ToLower(filename) { + if strings.EqualFold(filepath.Base(path), filename) { result = path // Exit WalkDir early, we've found our match return filepath.SkipAll