Golang : Get IP addresses of a domain name

Tags : golang lookupip ip-address domain

This small program demonstrate how to Golang's net.LookupIP() function to get the IP addresses from a given domain name.

 package main

 import (

 func main(){
 ip, _ := net.LookupIP(os.Args[1]) // take from 1st argument

Output :

go run getipaddress.go google.com

[ 2404:6800:4001:801::1008]

Reference :


Tags : golang lookupip ip-address domain

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.