Standard library / net
net.IP.Equal()
Compare address identity, treating equivalent IPv4 and mapped representations equally. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
func (ip IP) Equal(x IP) boolParameters & Attributes
| Name | Type | Description |
|---|---|---|
| x | IP | Other IP address. |
Return Value
bool
Operation result; check errors and validity indicators when returned.
Working Example
Example Snippetgo
package main
import ( "fmt" "net")
func main() { fmt.Println(net.ParseIP("192.0.2.7").Equal(net.IP{192, 0, 2, 7})) }
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) }}