Skip to the content.

Resolve Hostname To IP Address

net.LookupHost can be used to resolve hostnames to IP addresses.

Example

addresses, err := net.LookupHost("google.com")
if err != nil {
    fmt.Println("Unkown Host")
} else {
    fmt.Println("Addresses:", addresses)
}

Source: I Spy Code