code: func lookupAddr(ctx context.Context, resolver *net.Resolver, host string) (string, error) {
  	// Resolve the IP address or hostname to an IP address.
  	addrs, err := resolver.LookupIPAddr(ctx, host)
  	if err != nil {
  		return "", errors.Wrap(err, "looking up IP addresses")
  	}
  	if len(addrs) == 0 {
  		return "", fmt.Errorf("cannot resolve %q to an address", host)
  	}
  
  	// LookupIPAddr() can return a mix of IPv6 and IPv4
  	// addresses. Return the first IPv4 address if possible.
  	for _, addr := range addrs {
  		if ip := addr.IP.To4(); ip != nil {
  			return ip.String(), nil
  		}
  	}
  
  	// No IPv4 address, return the first resolved address instead.
  	return addrs[0].String(), nil
  }
docs: // lookupAddr resolves the given address/host to an IP address. If
  // multiple addresses are resolved, it returns the first IPv4 address
  // available if there is one, otherwise the first address.