Standard library / net
net.CIDRMask()
Build a contiguous mask for 32- or 128-bit addresses; invalid arguments return nil. Expected stdout: 'ffffff00\n'.
Formal Syntax & Structure
go syntaxgo
func CIDRMask(ones, bits int) IPMaskParameters & Attributes
| Name | Type | Description |
|---|---|---|
| ones | int | Number of leading one bits. |
| bits | int | Number of leading network bits. |
Return Value
IPMask
Operation result; check errors and validity indicators when returned.
Working Example
Example Snippetgo
package main
import ( "fmt" "net")
func main() { fmt.Println(net.CIDRMask(24, 32)) }
func must[T any](v T, e error) T { if e != nil { panic(e) } return v}func check(e error) { if e != nil { panic(e) }}