August 2019
Beginner to intermediate
798 pages
17h 2m
English
A very popular DNS request has to do with finding out the name servers of a domain, which are stored in the NS records of that domain. This functionality will be illustrated in the code for NSrecords.go.
The code for NSrecords.go will be presented in two parts.
The first part of NSrecords.go is as follows:
package main
import (
"fmt"
"net"
"os"
)
func main() {
arguments := os.Args
if len(arguments) == 1 {
fmt.Println("Need a domain name!")
return
}
In this part, you check whether you have at least one command-line argument in order to have something with which you can work.
The remaining Go code for NSrecords.go is as follows:
domain := arguments[1] NSs, err := net.LookupNS(domain) if err != nil { fmt.Println(err) ...Read now
Unlock full access