Skip to content

Commit

Permalink
fix(userinfo): use stdlib to find config dir
Browse files Browse the repository at this point in the history
  • Loading branch information
wfscheper committed Feb 26, 2023
1 parent 2a02d65 commit fe858b3
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 159 deletions.
12 changes: 4 additions & 8 deletions internal/userinfo/userinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,17 @@
package userinfo

import (
"errors"
"os/user"
"os"
"path/filepath"
)

// DefaultConfigFile returns the path to default location for a config file,
// based on the underlying OS.
func DefaultConfigFile(appName string) (string, error) {
u, err := user.Current()
configDir, err := os.UserConfigDir()
if err != nil {
return "", err
}
if u.HomeDir == "" {
return "", errors.New("cannot determine user specific home directory")
}
cfgDir := DefaultConfigDir(u.HomeDir)
return filepath.Join(cfgDir, appName, appName+".conf"), nil

return filepath.Join(configDir, appName, appName+".conf"), nil
}
21 changes: 0 additions & 21 deletions internal/userinfo/userinfo_darwin.go

This file was deleted.

25 changes: 0 additions & 25 deletions internal/userinfo/userinfo_darwin_test.go

This file was deleted.

27 changes: 0 additions & 27 deletions internal/userinfo/userinfo_linux.go

This file was deleted.

51 changes: 0 additions & 51 deletions internal/userinfo/userinfo_linux_test.go

This file was deleted.

27 changes: 0 additions & 27 deletions internal/userinfo/userinfo_windows.go

This file was deleted.

0 comments on commit fe858b3

Please sign in to comment.