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.2k Golang : Reclaim memory occupied by make() example
+30.1k Get client IP Address in Go
+7.1k Golang : Calculate how many weeks left to go in a given year
+10.2k Swift : Convert (cast) String to Integer
+7.6k Golang : Regular Expression find string example
+5.4k Golang : Frobnicate or tweaking a string example
+11.7k Golang : Convert a rune to unicode style string \u
+14.2k Golang : Reset buffer example
+5.6k Golang : Markov chains to predict probability of next state example
+7.2k Golang : Check to see if *File is a file or directory
+14k Golang : Recombine chunked files example