chmike / domain

Go function to check domain name validity
BSD 3-Clause "New" or "Revised" License
4 stars 1 forks source link

GoDoc Build codecov Go Report Status release

domain.Check()

This package contains a single function that checks the validity of a host name domain name.

A domain name must respect rules defined in

The domain.Check function ensures that the given host name respect those rules. If not, it returns an error explaining the detected problem.

Prerequisites

The package has no prerequisites and external dependencies.

Installation

To install or update this package use the instruction:

go get github.com/chmike/domain@latest

Usage examples

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)
}