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
+4k Google : Block or disable caching of your website content
+14.1k Golang : Get query string value on a POST request
+21.2k Golang : Convert Unix timestamp to UTC timestamp
+13.1k Golang : How to get URL port?
+13.9k Golang : Find location by IP address and display with Google Map
+28k Golang : missing Git command
+14.8k Golang : Generate universally unique identifier(UUID) example
+33.9k Golang : Get file last modified date and time
+7.2k Golang : Check if integer is power of four example
+6.3k Golang : How to handle file size larger than available memory panic issue
+28.8k Golang : Remove characters from string example
+14.2k Golang : Get current time from the Internet time server(ntp) example