diff --git a/net/net_linux.go b/net/net_linux.go index a2006ec13292c9307f57f0af8867ca54c196ca30..5d538f63520c0518d5104c9bf08c0b9c04b74295 100644 --- a/net/net_linux.go +++ b/net/net_linux.go @@ -217,32 +217,32 @@ var TCPStatuses = map[string]string{ type netConnectionKindType struct { family uint32 sockType uint32 - f string // file name + filename string } var kindTCP4 = netConnectionKindType{ family: syscall.AF_INET, sockType: syscall.SOCK_STREAM, - f: "tcp", + filename: "tcp", } var kindTCP6 = netConnectionKindType{ family: syscall.AF_INET6, sockType: syscall.SOCK_STREAM, - f: "tcp6", + filename: "tcp6", } var kindUDP4 = netConnectionKindType{ family: syscall.AF_INET, sockType: syscall.SOCK_DGRAM, - f: "udp", + filename: "udp", } var kindUDP6 = netConnectionKindType{ family: syscall.AF_INET6, sockType: syscall.SOCK_DGRAM, - f: "udp6", + filename: "udp6", } var kindUNIX = netConnectionKindType{ - family: syscall.AF_UNIX, - f: "unix", + family: syscall.AF_UNIX, + filename: "unix", } var netConnectionKindMap = map[string][]netConnectionKindType{ @@ -309,7 +309,7 @@ func NetConnectionsPid(kind string, pid int32) ([]NetConnectionStat, error) { for _, t := range tmap { var path string var ls []connTmp - path = fmt.Sprintf("%s/net/%s", root, t.f) + path = fmt.Sprintf("%s/net/%s", root, t.filename) switch t.family { case syscall.AF_INET: fallthrough @@ -456,7 +456,7 @@ func decodeAddress(family uint32, src string) (Addr, error) { } decoded, err := hex.DecodeString(addr) if err != nil { - return Addr{}, fmt.Errorf("decode error:", err) + return Addr{}, fmt.Errorf("decode error, %s", err) } var ip net.IP // Assumes this is little_endian diff --git a/net/net_linux_test.go b/net/net_linux_test.go index 55f1ec2616611cdc29b9d1af99eb47a81b119ef1..47faeb934eca04606ca97178ff5a5349b68cf430 100644 --- a/net/net_linux_test.go +++ b/net/net_linux_test.go @@ -68,3 +68,8 @@ func TestDecodeAddress(t *testing.T) { } } } + +func TestReverse(t *testing.T) { + src := []byte{0x01, 0x02, 0x03} + assert.Equal(t, []byte{0x03, 0x02, 0x01}, Reverse(src)) +} diff --git a/net/net_test.go b/net/net_test.go index 0bac45fef44d178d56ce53b8ae98c00cb74e076d..aabce8174e73b15bd67ce09077df63ca1ac1bd55 100644 --- a/net/net_test.go +++ b/net/net_test.go @@ -91,7 +91,7 @@ func TestNetIOCountersPerNic(t *testing.T) { } } -func Test_getNetIOCountersAll(t *testing.T) { +func TestGetNetIOCountersAll(t *testing.T) { n := []NetIOCountersStat{ NetIOCountersStat{ Name: "a",