Go program to find Forward(A) record of a domain
The net.LookupIP() function accepts a string(domain-name) and returns a slice of net.IP objects that contains host's IPv4 and IPv6 addresses.
Example
package main
import (
"fmt"
"net"
)
func main() {
iprecords, _ := net.LookupIP("facebook.com")
for _, ip := range iprecords {
fmt.Println(ip)
}
}
The output of above program lists the A records for facebook.com that were returned in IPv4 and IPv6 formats.
2a03:2880:f12f:83:face:b00c:0:25de
31.13.79.35
Most Helpful This Week
Example to compare Println vs Printf
How do you send an HTTP PATCH request in Go?
Golang program for implementation of Huffman Coding Algorithm
How to check if an item exists in Slice in Golang?
How do you handle HTTP requests in Go?
How To Make HTTP Requests in Go?
Multiple-value <function> in single-value context error in Golang
How do you handle HTTP server caching in Go?
Interface Accepting Address of the Variable in Golang
Expected <type>, but got <type> error in Golang