Standard library / net/netip
netip.Addr.Unmap()
Convert mapped IPv6 to IPv4; native IPv6 is unchanged. Expected stdout: '192.0.2.7\n'.
Formal Syntax & Structure
go syntaxgo
func (ip Addr) Unmap() AddrReturn Value
Addr
Operation result; check errors and validity indicators when returned.
Working Example
Example Snippetgo
package main
import ( "fmt" "net/netip")
func main() { fmt.Println(netip.MustParseAddr("::ffff:192.0.2.7").Unmap()) }
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) }}