This package contains a single function that checks the validity of a domain name.
A domain name must respect rules defined in
- section 3.5 of RFC 1034 ("Domain names - concepts and facilities")
- section 2 of RFC 1123 ("Requirements for Internet Hosts -- Application and Support")
The domain.Check
function ensures that the domain name respect those rules. If not, it returns an error explaining the detected problem.
The package has no prerequisites and external dependencies.
To install or update this package use the instruction:
go get -u "github.com/chmike/domain"
The Check
function can be used to check the validity of host or domain names.
name := "host.example.com"
if err := domain.Check(name); if err != nil {
log.Fatalf("invalid domain name '%s': %v", name, err)
}