Golang net.IPMask.Size() and String() functions example
package net
Golang net.IPMask.Size() and String() functions usage example
package main
import (
"fmt"
"net"
)
func main() {
ipv4mask := net.IPv4Mask(192, 168, 0, 1)
o, b := ipv4mask.Size()
fmt.Printf("IPv4Mask ones : %d\n", o)
fmt.Printf("IPv4Mask bits : %d\n", b)
fmt.Printf("IPv4Mask : %s\n", ipv4mask.String())
}
Output :
IPv4Mask ones : 0
IPv4Mask bits : 0
IPv4Mask : c0a80001
References :
Advertisement
Something interesting
Tutorials
+8.2k Golang : Add build version and other information in executables
+8.9k Golang : Find network service name from given port and protocol
+9.1k Golang : Serving HTTP and Websocket from different ports in a program example
+12k Golang : Find and draw contours with OpenCV example
+4.7k Javascript : Access JSON data example
+7.1k Golang : A simple forex opportunities scanner
+19.9k Golang : Count JSON objects and convert to slice/array
+13.6k Android Studio : Password input and reveal password example
+17.5k Golang : Clone with pointer and modify value
+80.6k Golang : How to return HTTP status code?