Documentation ¶
Overview ¶
Package domain provides parsing and processing of IDNA2008 compliant domain names and DNS labels.
Index ¶
- type Label
- type Name
- func (d Name) ASCIIString() string
- func (d Name) AddPrefix(labels ...Label) (Name, error)
- func (d Name) Compare(e Name) int
- func (d Name) CutSuffix(suffix Name) (rest []Label, found bool)
- func (d Name) Equal(e Name) bool
- func (d Name) Labels() []Label
- func (d Name) MustAddPrefix(labels ...Label) Name
- func (d Name) NumLabels() int
- func (d Name) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Label ¶
type Label struct {
// contains filtered or unexported fields
}
Label is a domain name label.
func ParseLabel ¶
ParseLabel parses and validates a domain name label.
s is validated and canonicalized into the Unicode form suitable for use in domain registrations, as defined by IDNA2008.
func (Label) ASCIIString ¶
func (Label) Compare ¶
Compare compares domain labels. It returns -1 if l < m, +1 if l > m, and 0 if l == m.
Compare returns 0 for labels that are equal as defined in IDNA2008. Unequal labels are ordered by lexical byte-wise comparison of their IDNA2008 canonical forms.
type Name ¶
type Name struct {
// contains filtered or unexported fields
}
Name is a fully qualified domain name.
A Name is always in valid, canonical Unicode form, according to the strictest ruleset for domain registration specified in IDNA2008 and Unicode Technical Standard #46.
func Parse ¶
Parse parses and validates a domain name string.
s is validated and canonicalized into the Unicode form suitable for use in domain registrations, as defined by IDNA2008.
func (Name) ASCIIString ¶
ASCIIString returns the domain name in its canonicalized ASCII (aka "punycode") form.
func (Name) AddPrefix ¶
AddPrefix returns d prefixed with labels.
For example, AddPrefix("qux", "bar") to "foo.com" is "qux.bar.foo.com".
func (Name) Compare ¶
Compare compares domain names. It returns -1 if d < e, +1 if d > e, and 0 if d == e.
Compare returns 0 for domain names that are equal as defined in IDNA2008. Unequal domain names are ordered according to Label.Compare of their first unequal label, starting from the TLD.
func (Name) CutSuffix ¶
CutSuffix removes suffix from d. If d is a child domain of suffix, CutSuffix returns the remaining leaf labels and found=true. Otherwise, it returns nil, false.
func (Name) MustAddPrefix ¶
MustAddPrefix is like AddPrefix, but panics if the formed prefix is invalid instead of returning an error.