Skip to content

Commit ca92585

Browse files
authored
Merge pull request #320 from dmur1/use-env-instead-of-etc-passwd-to-get-home-directory
use $HOME instead of parsing /etc/passwd to compute the path to ~/.co…
2 parents 143d8a8 + 38fd9ce commit ca92585

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

config/config.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package config
22

33
import (
44
"encoding/json"
5-
"fmt"
65
"log"
76
"os"
87
"os/user"
@@ -57,13 +56,7 @@ type Config struct {
5756
}
5857

5958
func ParseUserConfig() {
60-
currentUser, err := user.Current()
61-
if err != nil {
62-
fmt.Println("Error:", err)
63-
return
64-
}
65-
66-
configPath := filepath.Join(currentUser.HomeDir, UserConfig)
59+
configPath := filepath.Join(os.Getenv("HOME"), UserConfig)
6760

6861
jsonData, err := os.ReadFile(configPath)
6962
if err != nil {

0 commit comments

Comments
 (0)