转到:套接字库获取主机名

Is there any equivalent to python socket library in Go? https://docs.python.org/2/library/socket.html

I want to do something like this in Go:

import socket
ip = socket.gethostbyname(domain + ".multi.surbl.org")
# Translate a host name to IPv4 address format.

What package can I use to do this in Go?

Thanks!

The net namespace contains methods to translate hostnames to IP addresses (and a few other calls similar to what's in the Python socket namespace)

The call you're probably looking for is net.LookupHost or net.LookupIP;

addrs, err := net.LookupHost(hostname)