Skip to content

Commit 05d15df

Browse files
committed
Merge branch 'master' of https://github.com/abakum/go-netstat
2 parents 3d2d871 + c5cf502 commit 05d15df

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

netstat/netstat.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,22 @@ type SockTabEntry struct {
2525
Process *Process
2626
}
2727

28+
func (s SockTabEntry) String() string {
29+
l := ""
30+
if s.LocalAddr != nil {
31+
l = s.LocalAddr.String()
32+
}
33+
r := ""
34+
if s.RemoteAddr != nil {
35+
r = s.RemoteAddr.String()
36+
}
37+
p := ""
38+
if s.Process != nil {
39+
p = s.Process.String()
40+
}
41+
return fmt.Sprintf("%s %s %s %s", l, r, s.State, p)
42+
}
43+
2844
// Process holds the PID and process name to which each socket belongs
2945
type Process struct {
3046
Pid int

0 commit comments

Comments
 (0)