dnsname
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package dnsname contains string functions for working with DNS names.
Index¶
- func FirstLabel(hostname string) string
- func HasSuffix(name, suffix string) bool
- func NumLabels(hostname string) int
- func SanitizeHostname(hostname string) string
- func SanitizeLabel(label string) string
- func TrimCommonSuffixes(hostname string) string
- func TrimSuffix(name, suffix string) string
- func ValidHostname(hostname string) error
- func ValidLabel(label string) error
- type FQDN
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
funcFirstLabel¶added inv1.8.0
FirstLabel returns the first DNS label of hostname.
funcHasSuffix¶
HasSuffix reports whether the provided name ends with thecomponent(s) in suffix, ignoring any trailing or leading dots.
If suffix is the empty string, HasSuffix always reports false.
funcNumLabels¶added inv1.8.0
NumLabels returns the number of DNS labels in hostname.If hostname is empty or the top-level name ".", returns 0.
funcSanitizeHostname¶added inv1.6.0
SanitizeHostname turns hostname into a valid name label accordingtoRFC 1035.
funcSanitizeLabel¶added inv1.6.0
SanitizeLabel takes a string intended to be a DNS name labeland turns it into a valid name label according toRFC 1035.
funcTrimCommonSuffixes¶added inv1.6.0
TrimCommonSuffixes returns hostname with some common suffixes removed.
funcTrimSuffix¶added inv1.6.0
TrimSuffix trims any trailing dots from a name and removes thesuffix ending if present. The name will never be returned witha trailing dot, even after trimming.
funcValidHostname¶added inv1.40.0
ValidHostname checks if a string is a valid hostname.
funcValidLabel¶added inv1.38.0
ValidLabel reports whether label is a valid DNS label. All errors arevizerror.Error.
Types¶
typeFQDN¶added inv1.8.0
type FQDNstring
A FQDN is a fully-qualified DNS name or name suffix.
func (FQDN)WithTrailingDot¶added inv1.8.0
WithTrailingDot returns f as a string, with a trailing dot.
func (FQDN)WithoutTrailingDot¶added inv1.8.0
WithoutTrailingDot returns f as a string, with the trailing dotremoved.