From fde29d0733ca7fc57bfa31d78f7beeb43e275e6b Mon Sep 17 00:00:00 2001 From: Aadhavan Srinivasan Date: Fri, 17 Jan 2025 16:08:11 -0500 Subject: [PATCH] Construct config path using user's home directory, instead of trying to guess what the home directory is --- main.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index c417c80..e51fb46 100644 --- a/main.go +++ b/main.go @@ -7,7 +7,6 @@ import ( "fmt" "math" "os" - "os/user" "path/filepath" ) @@ -78,11 +77,11 @@ func main() { flag.Parse() // Check if config exists. If it doesn't, generate the config files. - currentUser, err := user.Current() // Get current user, to determine config path + userHomeDir, err := os.UserHomeDir() // Get current user's home directory, to construct config path if err != nil { panic(err) } - configPath := filepath.Join("/home/" + currentUser.Username + "/.config/ccat/") + configPath := filepath.Join(userHomeDir + "/.config/ccat/") if _, err := os.Stat(configPath); os.IsNotExist(err) { generateDefaultConfigs(configPath) }