@@ -34,7 +34,6 @@ func main() {
34
34
if err != nil {
35
35
log .Fatal ("Error getting executable path:" , err )
36
36
}
37
- exPath := filepath .Dir (ex )
38
37
39
38
address := flag .String ("url" , "" , "URL address (e.g., https://google.com)" )
40
39
showsuccessresult := flag .Bool ("v" , false , "Show success results only" )
@@ -60,8 +59,24 @@ func main() {
60
59
log .Fatal ("Error creating output directory:" , err )
61
60
}
62
61
}
63
-
64
- file , err := os .Open (exPath + "/Directory_list.txt" )
62
+ appPath , err := os .Executable ()
63
+ if err != nil {
64
+ fmt .Printf ("Failed to get application path: %v\n " , err )
65
+ return
66
+ }
67
+ filepathS := "Directory_list.txt"
68
+ appDir := filepath .Dir (appPath )
69
+ defaultLocalPath := filepath .Join (appDir , filepathS )
70
+ defaultGlobalPath := "/usr/local/bin/" + filepathS
71
+ fmt .Printf ("Checking for in %s\n and %s\n " , appDir , defaultGlobalPath )
72
+ // Check if the file exists in the application's directory
73
+ configfilepath := defaultLocalPath
74
+ if _ , err := os .Stat (configfilepath ); os .IsNotExist (err ) {
75
+ // If not found in the app directory, fall back to /usr/local/bin
76
+ fmt .Printf (" not found in %s, trying %s\n " , appDir , defaultGlobalPath )
77
+ configfilepath = defaultGlobalPath
78
+ }
79
+ file , err := os .Open (configfilepath )
65
80
if err != nil {
66
81
fmt .Printf ("%s" , err )
67
82
return
0 commit comments