Skip to content

Commit

Permalink
fixed code based on mcgrails suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
RanVaknin committed Oct 18, 2022
1 parent 79ab6a7 commit dd068e5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
15 changes: 14 additions & 1 deletion internal/shareddefaults/shared_config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package shareddefaults

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

Expand Down Expand Up @@ -29,5 +30,17 @@ func SharedConfigFilename() string {
// UserHomeDir returns the home directory for the user the process is
// running under.
func UserHomeDir() string {
return userHomeDir()
var home string

home = userHomeDir()
if len(home) > 0 {
return home
}

currUser, _ := user.Current()
if currUser != nil {
home = currUser.HomeDir
}

return home
}
11 changes: 0 additions & 11 deletions internal/shareddefaults/shared_config_resolve_home_go1.12.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,9 @@ package shareddefaults

import (
"os"
"os/user"
)

func userHomeDir() string {
home, _ := os.UserHomeDir()

if len(home) > 0 {
return home
}

currUser, _ := user.Current()
if currUser != nil {
home = currUser.HomeDir
}

return home
}

0 comments on commit dd068e5

Please sign in to comment.