File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed
Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff 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" )
You can’t perform that action at this time.
0 commit comments