From 3c2151d8d762a8bb7a6292468632b6a9e63c0b78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=B4=8D=E1=B4=8F=E1=B4=8F=C9=B4D4=CA=80=E1=B4=8B?= Date: Thu, 2 Jul 2020 13:08:38 +0800 Subject: [PATCH] format const name --- utils/utils_darwin.go | 27 +++++++++++---------------- utils/utils_windows.go | 42 +++++++++++++++++++++--------------------- 2 files changed, 32 insertions(+), 37 deletions(-) diff --git a/utils/utils_darwin.go b/utils/utils_darwin.go index b3cf730..473a8ac 100644 --- a/utils/utils_darwin.go +++ b/utils/utils_darwin.go @@ -14,15 +14,10 @@ import ( ) const ( - chromeDir = "/Users/*/Library/Application Support/Google/Chrome/*/" - edgeDir = "/Users/*/Library/Application Support/Microsoft Edge/*/" - //mac360Secure = "/Users/*/Library/Application Support/360Chrome/*/" -) - -const ( - Chrome = "Chrome" - Edge = "Microsoft Edge" - //Secure360 = "360" + chromeProfilePath = "/Users/*/Library/Application Support/Google/Chrome/*/" + chromeCommand = "Chrome" + edgeProfilePath = "/Users/*/Library/Application Support/Microsoft Edge/*/" + edgeCommand = "Microsoft Edge" ) var ( @@ -31,16 +26,16 @@ var ( chromeSalt = []byte("saltysalt") chromeKey []byte browserList = map[string]struct { - Dir string - Command string + ProfilePath string + Command string }{ "chrome": { - chromeDir, - Chrome, + chromeProfilePath, + chromeCommand, }, "edge": { - edgeDir, - Edge, + edgeProfilePath, + edgeCommand, }, } ) @@ -52,7 +47,7 @@ func DecryptStringWithDPAPI(data []byte) (string, error) { func PickBrowser(name string) (browserDir, command string, err error) { name = strings.ToLower(name) if choice, ok := browserList[name]; ok { - return choice.Dir, choice.Command, err + return choice.ProfilePath, choice.Command, err } return "", "", errBrowserNotSupported } diff --git a/utils/utils_windows.go b/utils/utils_windows.go index ccb091b..c0e14cb 100644 --- a/utils/utils_windows.go +++ b/utils/utils_windows.go @@ -14,38 +14,38 @@ import ( ) const ( - chromeDir = "/AppData/Local/Google/Chrome/User Data/*/" - chromeKeyFile = "/AppData/Local/Google/Chrome/User Data/Local State" - edgeDir = "/AppData/Local/Microsoft/Edge/User Data/*/" - edgeKeyFile = "/AppData/Local/Microsoft/Edge/User Data/Local State" - speed360Dir = "/AppData/Local/360chrome/Chrome/User Data/*/" - speed360KeyFile = "" - qqBrowserDir = "/AppData/Local/Tencent/QQBrowser/User Data/*/" - qqBrowserKeyFile = "" + chromeProfilePath = "/AppData/Local/Google/Chrome/User Data/*/" + chromeKeyPath = "/AppData/Local/Google/Chrome/User Data/Local State" + edgeProfilePath = "/AppData/Local/Microsoft/Edge/User Data/*/" + edgeKeyPath = "/AppData/Local/Microsoft/Edge/User Data/Local State" + speed360ProfilePath = "/AppData/Local/360chrome/Chrome/User Data/*/" + speed360KeyPath = "" + qqBrowserProfilePath = "/AppData/Local/Tencent/QQBrowser/User Data/*/" + qqBrowserKeyPath = "" ) var ( chromeKey []byte browserList = map[string]struct { - Dir string - Key string + ProfilePath string + KeyPath string }{ "chrome": { - chromeDir, - chromeKeyFile, + chromeProfilePath, + chromeKeyPath, }, "edge": { - edgeDir, - edgeKeyFile, + edgeProfilePath, + edgeKeyPath, }, "360speed": { - speed360Dir, - speed360KeyFile, + speed360ProfilePath, + speed360KeyPath, }, "qq": { - qqBrowserDir, - qqBrowserKeyFile, + qqBrowserProfilePath, + qqBrowserKeyPath, }, } ) @@ -53,10 +53,10 @@ var ( func PickBrowser(name string) (browserDir, key string, err error) { name = strings.ToLower(name) if choice, ok := browserList[name]; ok { - if choice.Key != "" { - return os.Getenv("USERPROFILE") + choice.Dir, os.Getenv("USERPROFILE") + choice.Key, nil + if choice.KeyPath != "" { + return os.Getenv("USERPROFILE") + choice.ProfilePath, os.Getenv("USERPROFILE") + choice.KeyPath, nil } else { - return os.Getenv("USERPROFILE") + choice.Dir, "", nil + return os.Getenv("USERPROFILE") + choice.ProfilePath, "", nil } } return "", "", errBrowserNotSupported