Standard library / net
net.TCPAddrFromAddrPort()
Convert numeric netip endpoint into the legacy address structure. Expected stdout: '192.0.2.7:80\n'.
Formal Syntax & Structure
go syntaxgo
func TCPAddrFromAddrPort(addr netip.AddrPort) *TCPAddrParameters & Attributes
| Name | Type | Description |
|---|---|---|
| addr | netip.AddrPort | Address value or address bytes in the required representation. |
Return Value
*TCPAddr
Operation result; check errors and validity indicators when returned.
Working Example
Example Snippetgo
package main
import ( "fmt" "net" "net/netip")
func main() { fmt.Println(net.TCPAddrFromAddrPort(netip.MustParseAddrPort("192.0.2.7:80"))) }
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) }}