How can I check whether URL.Hostname is a valid domain name? I am searching for the exact same behaviour as URI.CheckHostName in the .NET framework.
The function IsDNSName from the govalidator
package should do what you want. For details on installing it, see the README.
See my code here.
The function checks if the provided domain name is valid relative to the rules. It doesn't check if the domain name exist.