names

package
v0.0.0-...-67cf1be Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package names contains types that represent various types of internet names.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FQDN

type FQDN string

FQDN is a fully-qualified internet domain name.

func (FQDN) IsQualified

func (n FQDN) IsQualified() bool

IsQualified returns true.

func (FQDN) IsWithin

func (n FQDN) IsWithin(f FQDN) bool

IsWithin returns true if n is within the given FQDN.

It returns false if n and f are equal.

func (FQDN) Join

func (n FQDN) Join(s Name) Name

Join returns a name produced by concatenating this name with s. It panics if this name is fully qualified.

func (FQDN) Labels

func (n FQDN) Labels() []Label

Labels returns the DNS labels that form this name. It panics if the name is not valid.

func (FQDN) Qualify

func (n FQDN) Qualify(FQDN) FQDN

Qualify returns n unchanged.

func (FQDN) Split

func (n FQDN) Split() (head Label, tail Name)

Split splits the first label from the name. If the name only has single label, tail is nil. It panics if the name is not valid.

func (FQDN) String

func (n FQDN) String() string

String returns a representation of the name as used by DNS systems. It panics if the name is not valid.

func (FQDN) Validate

func (n FQDN) Validate() error

Validate returns nil if the name is valid.

type Label

type Label string

Label is the part of a DNS name contains within dots.

func (Label) IsQualified

func (n Label) IsQualified() bool

IsQualified returns false.

func (Label) Join

func (n Label) Join(s Name) Name

Join returns a name produced by concatenating this name with s. It panics if this name is fully qualified.

func (Label) Labels

func (n Label) Labels() []Label

Labels returns the DNS labels that form this name.

func (Label) Qualify

func (n Label) Qualify(f FQDN) FQDN

Qualify returns a fully-qualified domain name produced by "qualifying" this name with f.

func (Label) Split

func (n Label) Split() (head Label, tail Name)

Split splits the "hostname" from the name. If the name does not contain any dots, tail is nil.

func (Label) String

func (n Label) String() string

String returns a representation of the name as used by DNS systems. It panics if the name is not valid.

func (Label) Validate

func (n Label) Validate() error

Validate returns nil if the name is valid.

type Name

type Name interface {
	// IsQualified returns true if the name is fully-qualified.
	IsQualified() bool

	// Qualify returns a fully-qualified domain name produced by "qualifying"
	// this name with f.
	//
	// If this name is already qualified, it is returned unchanged.
	Qualify(f FQDN) FQDN

	// Labels returns the DNS labels that form this name.
	Labels() []Label

	// Split splits the first label from the name.
	// If the name only has single label, tail is nil.
	Split() (head Label, tail Name)

	// Join returns a name produced by concatenating this name with s.
	// It panics if this name is fully qualified.
	Join(s Name) Name

	// Validate returns nil if the name is valid.
	Validate() error

	// String returns a representation of the name as used by DNS systems.
	// It panics if the name is not valid.
	String() string
}

Name is an DNS name of some kind.

Any of the methods except Validate() MAY panic if the name is invalid.

func MustParse

func MustParse(n string) Name

MustParse parses an arbitrary internet name. It panics if n is invalid.

func Parse

func Parse(n string) (Name, error)

Parse parses an arbitrary internet name.

type UDN

type UDN string

UDN is a unqualified (relative) domain name that may multiple DNS labels.

func (UDN) IsQualified

func (n UDN) IsQualified() bool

IsQualified returns false.

func (UDN) Join

func (n UDN) Join(s Name) Name

Join returns a name produced by concatenating this name with s. It panics if this name is fully qualified.

func (UDN) Labels

func (n UDN) Labels() []Label

Labels returns the DNS labels that form this name. It panics if the name is not valid.

func (UDN) Qualify

func (n UDN) Qualify(f FQDN) FQDN

Qualify returns a fully-qualified domain name produced by "qualifying" this name with f.

func (UDN) Split

func (n UDN) Split() (head Label, tail Name)

Split splits the first label from the name. If the name only has single label, tail is nil.

func (UDN) String

func (n UDN) String() string

String returns a representation of the name as used by DNS systems. It panics if the name is not valid.

func (UDN) Validate

func (n UDN) Validate() error

Validate returns nil if the name is valid.

Jump to

Keyboard shortcuts

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