multiwhois is a Go package for querying and parsing domain information from WHOIS servers.
It uses the github.com/domainr/whois package to fetch the WHOIS information and parses the response into a struct containing the domain owner, expiration date, and availability status.
It currently supports parsing WHOIS information for the following TLDs:
.com.info.be.nl
To install the package, use the following command:
go get github.com/melvinsh/multiwhois
package main
import (
"fmt"
"github.com/melvinsh/multiwhois"
)
func main() {
info, err := multiwhois.QueryDomainInfo("google.com")
if err != nil {
panic(err)
}
fmt.Println("Domain:", info.Domain)
fmt.Println("Available:", info.IsAvailable)
fmt.Println("Expiration:", info.Expiration)
fmt.Println("Full WHOIS response:", info.FullWhois)
}The QueryDomainInfo function takes a domain name as its argument and returns a *DomainInfo struct and an error. The *DomainInfo struct contains the following fields:
Domain(string): the domain nameExpiration(time.Time): the expiration date of the domainIsAvailable(bool): whether the domain is available or notFullWhois(string): the full WHOIS response
To run the tests, use the following command:
go test github.com/melvinsh/multiwhois
multiwhois uses YAML files to configure the regex patterns for parsing WHOIS responses. The YAML files are located in the tlds directory and are named after the TLD they represent (e.g. com.yml for the .com TLD).
The YAML file can contain the following fields, depending on which information is returned by the WHOIS servers for each TLD:
availability(string): a regex pattern for determining the availability of the domainexpiration(string): a regex pattern for extracting the expiration date from the WHOIS responseexpiration_format(string): the format used to parsed the expiration time
Here is an example YAML file for the .com TLD:
expiration: 'Registry Expiry Date: ([^\r\n]+)'
expiration_format: '2006-01-02T15:04:05Z'
availability: 'No match for'