code: func newChallenge(domain, keyAuth string, tlds map[string]string) (*challenge, error) {
  	domain = dns01.UnFqdn(domain)
  	parts := strings.Split(domain, ".")
  
  	// Find the longest matching TLD.
  	longest := -1
  	for i := len(parts); i > 0; i-- {
  		t := strings.Join(parts[i-1:], ".")
  		if _, found := tlds[t]; found {
  			longest = i - 1
  		}
  	}
  	if longest < 1 {
  		return nil, fmt.Errorf("invalid domain name %q", domain)
  	}
  
  	tld := strings.Join(parts[longest:], ".")
  	sld := parts[longest-1]
  
  	var host string
  	if longest >= 1 {
  		host = strings.Join(parts[:longest-1], ".")
  	}
  
  	fqdn, value := dns01.GetRecord(domain, keyAuth)
  
  	return &challenge{
  		domain:   domain,
  		key:      "_acme-challenge." + host,
  		keyFqdn:  fqdn,
  		keyValue: value,
  		tld:      tld,
  		sld:      sld,
  		host:     host,
  	}, nil
  }
docs: // newChallenge builds a challenge record from a domain name, a challenge
  // authentication key, and a map of available TLDs.