Golang : Get IP addresses of a domain name
This small program demonstrate how to Golang's net.LookupIP() function to get the IP addresses from a given domain name.
package main
import (
"fmt"
"net"
"os"
)
func main(){
ip, _ := net.LookupIP(os.Args[1]) // take from 1st argument
fmt.Println(ip)
}
Output :
go run getipaddress.go google.com
[173.194.126.37 173.194.126.34 173.194.126.40 173.194.126.32 173.194.126.36 173.194.126.41 173.194.126.33 173.194.126.38 173.194.126.46 173.194.126.35 173.194.126.39 2404:6800:4001:801::1008]
Reference :
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+5.5k Golang : Embedded or data bundling example
+6.4k Golang : Individual and total number of words counter example
+11.3k Golang : Sort and reverse sort a slice of bytes
+8.4k Facebook : Getting the friends list with PHP return JSON format
+6.8k Javascript : Put image into Chrome browser's console
+12.8k Elastic Search : Mapping date format and sort by date
+5.2k Golang : How to solve "too many .rsrc sections" error?
+15.4k Golang : Gzip file example
+37.6k Golang : How to read CSV file
+29.3k Golang : How to convert(cast) string to IP address?
+24.6k Golang : missing Mercurial command
+11.2k Golang : Arithmetic operation with numerical slices or arrays example