Standard library / net/netip
netip.Prefix.IsSingleIP()
Report whether the prefix contains exactly one IP. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
func (p Prefix) IsSingleIP() boolReturn Value
bool
Operation result; check errors and validity indicators when returned.
Working Example
Example Snippetgo
package main
import ( "fmt" "net/netip")
func main() { fmt.Println(netip.MustParsePrefix("192.0.2.7/32").IsSingleIP()) }
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) }}