<commit_before>package whois

import (
	"errors"
	"strings"
)

// Whois queries a whois server for q and returns the result.
func Whois(q string) (string, error) {
	req, err := Resolve(q)
	if err != nil {
		return "", err
	}

	res, err := req.Fetch()
	if err != nil {
		return "", err
	}

	return string(res.Body), nil
}

// Resolve finds a whois server for q and prepares a Request.
func Resolve(q string) (*Request, error) {
	req := NewRequest(q)

	labels := strings.Split(q, ".")
	zone := labels[len(labels)-1]

	req.Host = zones[zone]
	if req.Host == "" {
		return req, errors.New("No whois server found for " + q)
	}

	srv, ok := servers[req.Host]
	if !ok {
		srv = defaultServer
	}
	srv.Resolve(req)

	return req, nil
}<commit_msg>Lake Shasta code review courtesy @bradfitz<commit_after>package whois

import (
	"errors"
	"strings"
)

// Whois queries a whois server for q and returns the result.
func Whois(q string) (string, error) {
	req, err := Resolve(q)
	if err != nil {
		return "", err
	}

	res, err := req.Fetch()
	if err != nil {
		return "", err
	}

	return string(res.Body), nil
}

// Resolve finds a whois server for q and prepares a Request.
func Resolve(q string) (*Request, error) {
	req := NewRequest(q)

	labels := strings.Split(q, ".")
	zone := labels[len(labels)-1]

	var ok bool
	req.Host, ok = zones[zone]
	if !ok {
		return req, errors.New("No whois server found for " + q)
	}

	srv, ok := servers[req.Host]
	if !ok {
		srv = defaultServer
	}
	srv.Resolve(req)

	return req, nil
}
{'fraction_non_alphanumeric': 0.145791915175613, 'fraction_numerical': 0.0013253810470510272, 'mean_word_length': 3.339080459770115, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2663478', 'n_tokens_mistral': 584, 'n_tokens_neox': 560, 'n_words': 179}