Golang net.IPMask type, CIDRMask() and IPv4Mask() functions example
package net
Golang net.IPMask type, CIDRMask() and IPv4Mask() functions usage example
package main
import (
"fmt"
"net"
)
func main() {
ipmask := net.CIDRMask(2, 32)
fmt.Printf("CIDRMask : %#v\n", ipmask)
ipv4mask := net.IPv4Mask(192, 168, 0, 1)
fmt.Printf("IPv4Mask : %#v\n", ipv4mask)
}
Output :
CIDRMask : net.IPMask{0xc0, 0x0, 0x0, 0x0}
IPv4Mask : net.IPMask{0xc0, 0xa8, 0x0, 0x1}
References :
http://golang.org/pkg/net/#IPMask
Advertisement
Something interesting
Tutorials
+11.2k CodeIgniter : How to check if a session exist in PHP?
+13.8k Golang : unknown escape sequence error
+10.6k Golang : Flip coin example
+30.8k Golang : Download file example
+8.2k Prevent Write failed: Broken pipe problem during ssh session with screen command
+5.3k PHP : Hide PHP version information from curl
+8.2k Golang : Get final or effective URL with Request.URL example
+7.9k Golang : Grayscale Image
+17.9k Golang : How to make a file read only and set it to writable again?
+9.3k Golang : Generate EAN barcode
+6.2k Golang : Process non-XML/JSON formatted ASCII text file example
+16.3k Golang : Loop each day of the current month example