a simple Go WHOIS Client API.
Lookup(ctx context.Context, domain, server string) (string, error)
WHOISHost(domain string) (string, error)
TLDs() []string
go get github.com/twiny/whois/v2
package main
import (
"context"
"fmt"
"time"
"github.com/twiny/whois/v2"
)
func main() {
domain := "google.com"
// to use Socks5 - this format 'socks5://username:password@alpha.hostname.com:1023'
// otherwise use 'whois.Localhost' to use local connection
client, err := whois.NewClient(whois.Localhost)
if err != nil {
fmt.Println(err)
return
}
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
host, err := client.WHOISHost(domain)
if err != nil {
fmt.Println(err)
return
}
resp, err := client.Lookup(ctx, "google.com", host)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(resp)
fmt.Println("done.")
}
-
If you wish to add more WHOIS Server please create a PR.
-
If you find any issues please create a new issue.