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
+8k Golang : Oanda bot with Telegram and RSI example
+4.6k Python : Find out the variable type and determine the type with simple test
+13.2k Golang : Read XML elements data with xml.CharData example
+7.7k Golang : Handle Palindrome string with case sensitivity and unicode
+11.8k Linux : How to install driver for 600Mbps Dual Band Wifi USB Adapter
+11.3k Golang : Concurrency and goroutine example
+5.7k Golang : Shuffle array of list
+6.3k Golang : How to determine if request or crawl is from Google robots
+4.6k Which content-type(MIME type) to use for JSON data
+9.4k Golang : Copy map(hash table) example
+7.9k Golang : Routes multiplexer routing example with regular expression control
+11k Golang : Delay or limit HTTP requests example