Skip to content

Commit

Permalink
Add a Reset function
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellh committed Jan 27, 2019
1 parent ae18d6b commit af06845
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions homedir.go
Expand Up @@ -76,6 +76,16 @@ func Expand(path string) (string, error) {
return filepath.Join(dir, path[1:]), nil
}

// Reset clears the cache, forcing the next call to Dir to re-detect
// the home directory. This generally never has to be called, but can be
// useful in tests if you're modifying the home directory via the HOME
// env var or something.
func Reset() {
cacheLock.Lock()
defer cacheLock.Unlock()
homedirCache = ""
}

func dirUnix() (string, error) {
homeEnv := "HOME"
if runtime.GOOS == "plan9" {
Expand Down

0 comments on commit af06845

Please sign in to comment.