This package contains a single function that checks the validity of a host name 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 given host 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 github.com/chmike/domain@latest
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 host name '%s': %v", name, err)
}