/whois

golang wrapper for whois command

Primary LanguageGoMIT LicenseMIT

whois - a go wrapper for whois command

go report card MIT license GoDoc

Examples

Query by URL:

url := "http://github.com/xellio/whois"
res, err := whois.Query(url)
if err != nil {
	fmt.Println(err)
	return
}
fmt.Println(strings.Join(res.Output["Registrant City"], ","))
//Output:
//San Francisco

Query by hostname:

host := "golang.org"
res, err := whois.QueryHost(host)
if err != nil {
	fmt.Println(err)
	return
}
fmt.Println(strings.Join(res.Output["Registrant Country"], ","))
// Output:
// US

Query by IP:

ip := net.ParseIP("8.8.8.8")
res, err := whois.QueryIp(ip)
if err != nil {
	fmt.Println(err)
	return
}
fmt.Println(strings.Join(res.Output["CIDR"], ","))
// Output:
// 8.0.0.0/8,8.8.8.0/24