Skip to content

Commit 0aaf087

Browse files
author
invoker
committed
update SensitiveList path
1 parent 6ad33bf commit 0aaf087

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

main.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,24 @@ func main() {
6464
// panic(err)
6565
//}
6666
//exPath := filepath.Dir(ex)
67+
appPath, err := os.Executable()
68+
if err != nil {
69+
fmt.Printf("Failed to get application path: %v\n", err)
70+
return
71+
}
72+
appDir := filepath.Dir(appPath) // Directory where the application is running
6773

68-
configfilepath := "./SensitiveList.json"
69-
if *configfile != "" {
70-
configfilepath = *configfile
74+
// Default paths
75+
defaultLocalPath := filepath.Join(appDir, "SensitiveList.json") // ./SensitiveList.json
76+
defaultGlobalPath := "/usr/local/bin/SensitiveList.json" // /usr/local/bin/SensitiveList.json
77+
78+
// Check if the file exists in the application's directory
79+
configfilepath := defaultLocalPath
80+
if _, err := os.Stat(configfilepath); os.IsNotExist(err) {
81+
// If not found in the app directory, fall back to /usr/local/bin
82+
configfilepath = defaultGlobalPath
7183
}
84+
7285
jsonFile, err := os.Open(configfilepath)
7386
if err != nil {
7487
fmt.Printf("%s", "Can not read json file")

0 commit comments

Comments
 (0)