package network import ( "fmt" "testing" ) func Test_IsPrivateIp(t *testing.T) { str := "10.1.77.54" is := IsPrivateIp(str) fmt.Println("is private ip", is) } func Test_GetLocalIps(t *testing.T) { ips := GetLocalIps() fmt.Println(ips) } func Test_GetInternetIps(t *testing.T) { ips := GetInternetIps() fmt.Println(ips) } func Test_GetNumber(t *testing.T) { ip := "192.168.122.21" mask := "255.255.255.0" n, err := GetNumber(ip, mask) t.Log(n, err) ip = "192.168.112.253" mask = "255.255.120.0" n, err = GetNumber(ip, mask) t.Log(n, err) ip = "172.16.23.23" mask = "255.255.255.0" n, err = GetNumber(ip, mask) t.Log(n, err) } func Test_GetIpMaskFromCIDR(t *testing.T) { ip := "192.168.141.22/24" ip, mask, err := GetIpMaskFromCIDR(ip) t.Log(ip, mask, err) } func Test_ChangeMask(t *testing.T) { mask := "255.255.255.0" a := ChangeMask(mask) t.Log(a) }