Skip to content

Commit

Permalink
fix error handling and if statement that was always false
Browse files Browse the repository at this point in the history
  • Loading branch information
tjex committed Sep 1, 2024
1 parent 524ed29 commit 58c14eb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/util/paths/paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,18 @@ func WriteString(path string, content string) error {
}

// Expands environment variables and `~`, returning an absolute path.
// On error, an empty string is returned.
func ExpandPath(path string) (string, error) {

if strings.HasPrefix(path, "~/") {
if strings.HasPrefix(path, "~") {
// resolve necessary variables
usr, err := user.Current()
if err != nil {
return "", err
}
home := usr.HomeDir
if home == "" {
return "", errors.New("Could not find user's home directory.")
err := errors.New("Could not find user's home directory.")
return "", err
}

// construct as abs path
Expand Down

0 comments on commit 58c14eb

Please sign in to comment.