dns - Get domain name from IP address in Go -
i'm trying resolve host name ip address, apparently proving little more challenging thought it'd be.
i've tried using couple of functions, including net.lookuphost
method, of them seem returning ip address input.
here's code using:
package main import ( "fmt" "net" ) func main() { // obtained ping -c 1 stackoverflow.com, should print "stackoverflow.com" addr, err := net.lookuphost("198.252.206.16") fmt.println(addr, err) }
for example,
package main import ( "fmt" "net" ) func main() { // obtained ping -c 1 stackoverflow.com, should print "stackoverflow.com" addr, err := net.lookupaddr("198.252.206.16") fmt.println(addr, err) }
output:
[stackoverflow.com.] <nil>
Comments
Post a Comment