Standard library / net
net.IPMask.Size()
Return leading one bits and total bits; noncanonical masks return 0,0. Expected stdout: '24 32\n'.
Formal Syntax & Structure
go syntaxgo
func (m IPMask) Size() (ones, bits int)Return Value
(ones, bits int)
Operation result; check errors and validity indicators when returned.
Working Example
Example Snippetgo
package main
import ( "fmt" "net")
func main() { o, b := net.CIDRMask(24, 32).Size(); fmt.Println(o, b) }
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) }}