File tree 1 file changed +11
-7
lines changed
1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -82,12 +82,12 @@ func main() {
82
82
}
83
83
defer file .Close ()
84
84
85
- // Scan through each line of the file
85
+ // use a map to dedupe .so libraries
86
+ soFiles := make (map [string ]bool )
87
+
86
88
scanner := bufio .NewScanner (file )
87
89
for scanner .Scan () {
88
90
line := scanner .Text ()
89
-
90
- // Split the line by spaces to get the different fields
91
91
fields := strings .Fields (line )
92
92
if len (fields ) == 0 {
93
93
continue
@@ -100,10 +100,14 @@ func main() {
100
100
if strings .HasSuffix (libPath , ".so" ) || strings .Contains (libPath , ".so." ) {
101
101
// get the absolute path of the shared library
102
102
absPath , err := filepath .EvalSymlinks (libPath )
103
- if err == nil {
103
+ if err != nil {
104
+ absPath = libPath
105
+ }
106
+
107
+ // dedupe .so against map
108
+ if ! soFiles [absPath ] {
109
+ soFiles [absPath ] = true
104
110
fmt .Println (absPath )
105
- } else {
106
- fmt .Println (libPath )
107
111
}
108
112
}
109
113
}
@@ -118,7 +122,7 @@ func isNumeric(arg string) bool {
118
122
return err == nil
119
123
}
120
124
121
- // Helper function to get the maximum possible PID from /proc/sys/kernel/pid_max
125
+ // get the maximum possible PID from /proc/sys/kernel/pid_max
122
126
func getMaxPid () (int , error ) {
123
127
data , err := ioutil .ReadFile ("/proc/sys/kernel/pid_max" )
124
128
if err != nil {
You can’t perform that action at this time.
0 commit comments