dnsname

package
v1.33.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2022 License: BSD-3-Clause Imports: 2 Imported by: 0

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

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

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

func SanitizeHostname(hostname string) string

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

func SanitizeLabel

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

func TrimCommonSuffixes(hostname string) string

TrimCommonSuffixes returns hostname with some common suffixes removed.

func TrimSuffix

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.

Types

type FQDN

type FQDN string

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

func ToFQDN

func ToFQDN(s string) (FQDN, error)

func (FQDN) Contains

func (f FQDN) Contains(other FQDN) bool

func (FQDN) NumLabels

func (f FQDN) NumLabels() int

func (FQDN) WithTrailingDot

func (f FQDN) WithTrailingDot() string

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

func (FQDN) WithoutTrailingDot

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