dnsname

package
v1.62.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 26, 2024 License: BSD-3-Clause Imports: 3 Imported by: 55

Documentation

Overview

Package dnsname contains string functions for working with DNS names.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FirstLabel added in v1.8.0

func FirstLabel(hostname string) string

FirstLabel returns the first DNS label of hostname.

func HasSuffix

func HasSuffix(name, suffix string) bool

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

func NumLabels(hostname string) int

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

func SanitizeHostname(hostname string) string

SanitizeHostname turns hostname into a valid name label according to RFC 1035.

func SanitizeLabel added in v1.6.0

func SanitizeLabel(label string) string

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

func TrimCommonSuffixes(hostname string) string

TrimCommonSuffixes returns hostname with some common suffixes removed.

func TrimSuffix added in v1.6.0

func TrimSuffix(name, suffix string) string

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.

func ValidHostname added in v1.40.0

func ValidHostname(hostname string) error

ValidHostname checks if a string is a valid hostname.

func ValidLabel added in v1.38.0

func ValidLabel(label string) error

ValidLabel reports whether label is a valid DNS label.

Types

type FQDN added in v1.8.0

type FQDN string

A FQDN is a fully-qualified DNS name or name suffix.

func ToFQDN added in v1.8.0

func ToFQDN(s string) (FQDN, error)

func (FQDN) Contains added in v1.8.0

func (f FQDN) Contains(other FQDN) bool

func (FQDN) NumLabels added in v1.8.0

func (f FQDN) NumLabels() int

func (FQDN) WithTrailingDot added in v1.8.0

func (f FQDN) WithTrailingDot() string

WithTrailingDot returns f as a string, with a trailing dot.

func (FQDN) WithoutTrailingDot added in v1.8.0

func (f FQDN) WithoutTrailingDot() string

WithoutTrailingDot returns f as a string, with the trailing dot removed.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL