From 6ced549deaecb42b9bb93ea9efcb4c1bbaabe8a4 Mon Sep 17 00:00:00 2001 From: mhsanaei Date: Sat, 20 Sep 2025 09:35:50 +0200 Subject: docs: add comments for all functions --- util/sys/sys_linux.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'util/sys/sys_linux.go') diff --git a/util/sys/sys_linux.go b/util/sys/sys_linux.go index 8a494d62..23483b57 100644 --- a/util/sys/sys_linux.go +++ b/util/sys/sys_linux.go @@ -45,6 +45,8 @@ func getLinesNum(filename string) (int, error) { return sum, nil } +// GetTCPCount returns the number of active TCP connections by reading +// /proc/net/tcp and /proc/net/tcp6 when available. func GetTCPCount() (int, error) { root := HostProc() @@ -75,6 +77,8 @@ func GetUDPCount() (int, error) { return udp4 + udp6, nil } +// safeGetLinesNum returns 0 if the file does not exist, otherwise forwards +// to getLinesNum to count the number of lines. func safeGetLinesNum(path string) (int, error) { if _, err := os.Stat(path); os.IsNotExist(err) { return 0, nil -- cgit v1.2.3