import "net" func main() { addr, err := net.ResolveTCPAddr("tcp", "127.0.0.1:9000") if err != nil { panic(err) } println(addr.String()) }
import "net" func main() { addr := &net.UDPAddr{ IP: net.ParseIP("127.0.0.1"), Port: 9000, } println(addr.String()) }In this example, we are manually creating a `net.UDPAddr` struct for a given IP address and port number. The `net.ParseIP` function is used to convert a string representation of the IP address into a `net.IP` type. The resulting `addr` variable is also of type `*net.UDPAddr`, which provides methods for accessing the IP address and port number separately. Package library: net.