Standard library / net

net.ResolveUDPAddr()

Resolve a numeric endpoint into a typed address. Names can trigger DNS; this example uses numeric input. Expected stdout: '192.0.2.7:80\n'.

Formal Syntax & Structure

go syntaxgo
func ResolveUDPAddr(network, address string) (*UDPAddr, error)

Parameters & Attributes

NameTypeDescription
networkstringNetwork family such as tcp4 or udp4.
addressstringNetwork address including port when required.

Return Value

(*UDPAddr, error)

Operation result; check errors and validity indicators when returned.

Working Example

Example Snippetgo
package main
import (  "fmt"  "net")
func main() { fmt.Println(must(net.ResolveUDPAddr("udp4", "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)  }}
Go Reference