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
- type FQDN
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FirstLabel ¶ added in v1.8.0
FirstLabel returns the first DNS label of hostname.
func HasSuffix ¶
HasSuffix reports whether the provided name ends with the component(s) in suffix, ignoring any trailing or leading dots.
If suffix is the empty string, HasSuffix always reports false.
func NumLabels ¶ added in v1.8.0
NumLabels returns the number of DNS labels in hostname. If hostname is empty or the top-level name ".", returns 0.
func SanitizeHostname ¶ added in v1.6.0
SanitizeHostname turns hostname into a valid name label according to RFC 1035.
func SanitizeLabel ¶ added in v1.6.0
SanitizeLabel takes a string intended to be a DNS name label and turns it into a valid name label according to RFC 1035.
func TrimCommonSuffixes ¶ added in v1.6.0
TrimCommonSuffixes returns hostname with some common suffixes removed.
func TrimSuffix ¶ added in v1.6.0
TrimSuffix trims any trailing dots from a name and removes the suffix ending if present. The name will never be returned with a trailing dot, even after trimming.
Types ¶
type FQDN ¶ added in v1.8.0
type FQDN string
A FQDN is a fully-qualified DNS name or name suffix.
func (FQDN) WithTrailingDot ¶ added in v1.8.0
WithTrailingDot returns f as a string, with a trailing dot.
func (FQDN) WithoutTrailingDot ¶ added in v1.8.0
WithoutTrailingDot returns f as a string, with the trailing dot removed.