hostname

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: GPL-3.0, LGPL-3.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package hostname decides whether a name may be handed to ssh or put into a URL as a host.

A node name reaches places that give some characters a meaning: ssh reads a leading "-" as an option, and a URL reads ":", "@", "/", "?" and "#" as the port, the userinfo, the path, the query and the fragment. Checking each place for the characters it happens to care about would miss the next one, so a name is accepted only when it is spelled in the host name alphabet of RFC 1123, in which none of them has a meaning.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(name string) error

Check reports whether name is a host name: dot separated labels of ASCII letters, digits and hyphens, none of them empty, none longer than 63 characters, and none beginning or ending with a hyphen. A single final dot is allowed, since it only says the name is fully qualified.

An IPv4 address in dotted form passes, because it is spelled in the same alphabet. An IPv6 address does not; use CheckHost where one is expected.

func CheckHost

func CheckHost(host string) error

CheckHost reports whether host names a machine on its own: a host name as Check accepts it, or an IPv4 or IPv6 address. Anything that would add a port, an account, a zone or a path to the host is refused.

func IsIP

func IsIP(host string) bool

IsIP reports whether host is an IPv4 or IPv6 address without a zone, and without the brackets a URL puts around an IPv6 address.

Types

This section is empty.

Jump to

Keyboard shortcuts

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