Go: Socket Library to Get Hostname
Is There Any Equivalent to Python Socket Library in Go? I Want to Do Something Like This in Go: Import Socket Ip = Socket. Gethostbyname(Domain + ". Multi...
Is there any equivalent to python socket library in Go?
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!
1 Answer
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)