From 2a242c8f26c1ec3abe91e885f7a910f10d773fc2 Mon Sep 17 00:00:00 2001 From: Nilesh Patra Date: Sat, 1 Jul 2023 14:35:25 +0530 Subject: [PATCH] Make debug dir specific to username to ease off multi user logins --- debug/debug.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/debug/debug.go b/debug/debug.go index cb4587d..625476a 100644 --- a/debug/debug.go +++ b/debug/debug.go @@ -22,6 +22,7 @@ import ( "io" "io/ioutil" "os" + "os/user" "path/filepath" "runtime/debug" "time" @@ -34,7 +35,17 @@ var RecoverPrettyPanic bool var DeadlockDetection bool var WriteLogs bool var OnRecover func() -var LogDirectory = filepath.Join(os.TempDir(), "gomuks") +var LogDirectory = filepath.Join(os.TempDir(), "gomuks-" + getUname()) + +func getUname() string { + currUser, err := user.Current() + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + return currUser.Username +} func Initialize() { err := os.MkdirAll(LogDirectory, 0750)