appdir
Where a Go tool keeps its files, from the global and project homes to the prod/dev profile split, pointer keys and moving an old home, each path with the rule that picked it.
go get github.com/ubgo/appdir
- Language
- Go
- Go version
- 1.24
- Core deps
- 0 direct
- Latest tag
- v0.1.0
- License
- Apache-2.0
- Go modules
- 1
Code from the README
// open resolves every home for the app. The three seams keep the example
// away from the real machine: the user's home, the working folder and the
// environment all come from the caller. WithRelease(true) keeps the prod
// profile, so folders have their plain names (.lore, not .lore-dev).
func open(home, workDir string) (*appdir.Dirs, error) {
d, err := appdir.New(appName,
appdir.WithHomeDir(func() (string, error) { return home, nil }),
appdir.WithWorkDir(workDir),
appdir.WithEnv(func(string) (string, bool) { return "", false }),
appdir.WithRelease(true),
)
if err != nil {
return nil, fmt.Errorf("appdir: %w", err)
}
return d, nil
}From the appdir README.