Standard library / net/netip
netip.Prefix.Overlaps()
Report whether two prefixes share at least one address in the same family. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
func (p Prefix) Overlaps(o Prefix) boolParameters & Attributes
| Name | Type | Description |
|---|---|---|
| o | Prefix | Other prefix to test for overlap. |
Return 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/24").Overlaps(netip.MustParsePrefix("192.0.2.128/25")))}
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) }}