Categorygithub.com/jbenet/go-is-domain
modulepackage
1.0.5
Repository: https://github.com/jbenet/go-is-domain.git
Documentation: pkg.go.dev

# README

go-is-domain

This package is dedicated to @whyrusleeping.

Docs: https://godoc.org/github.com/jbenet/go-is-domain

Check whether something is a domain.


import (
  isd "github.com/jbenet/go-is-domain"
)

isd.IsDomain("foo.com") // true
isd.IsDomain("foo.bar.com.") // true
isd.IsDomain("foo.bar.baz") // false

MIT Licensed

Updating TLDs

To update non-extended TLDs, IANA publishes, you can retrieve them from data.iana.org.

After retrieving the updated list, enter them into the file tlds-alpha-by-domain.txt. In order to update the TLDs map in tlds.go, you can run the gen.sh script which will generate the contents of a string -> bool map. After that, you'll want to replace the contents of the existing TLDs map, with the one that was generated and stored in formatted_tlds.txt

# Functions

IsDomain returns whether given string is a domain.
IsExtendedTLD returns whether the given string is a TLD (Top Level Domain), extended with a few other "TLDs": .bit, .onion.
IsICANNTLD returns whether the given string is a TLD (Top Level Domain), according to ICANN.
IsTLD returns whether the given string is a TLD (according to ICANN, or in the set of ExtendedTLDs listed in this package.

# Constants

DomainRegexpStr is a regular expression string to validate domains.

# Variables

ExtendedTLDs is a set of additional "TLDs", allowing decentralized name systems, like TOR and Namecoin.
# Version 2020051300, Last Updated Wed May 13 07:07:01 2020 UTC.