avoid using the user.Current on windows to avoid slow startup (#1617)
* avoid using the user.Current on windows to avoid slow startup * formated os_windows.go
This commit is contained in:
1 parent
0c02239b17
commit
8ee8592b91
1 file changed
+11
-5
+11
-5
@@ -59,14 +59,20 @@ func init() {
|
||||
envShell = "cmd"
|
||||
}
|
||||
|
||||
u, err := user.Current()
|
||||
homeDir, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
log.Printf("user: %s", err)
|
||||
panic(err)
|
||||
}
|
||||
gUser = u
|
||||
|
||||
// remove domain prefix
|
||||
gUser.Username = strings.Split(gUser.Username, `\`)[1]
|
||||
username := os.Getenv("USERNAME")
|
||||
if username == "" {
|
||||
panic("$USERNAME variable is empty or not set")
|
||||
}
|
||||
|
||||
gUser = &user.User{
|
||||
HomeDir: homeDir,
|
||||
Username: username,
|
||||
}
|
||||
|
||||
data := os.Getenv("LF_CONFIG_HOME")
|
||||
if data == "" {
|
||||
|
||||
Reference in new issue
Block a user