fqdn

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2024 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFqdnNotFound = errors.New("fqdn not found")

ErrFqdnNotFound is returned when fully qualified hostname cannot be found.

Functions

func Hostname

func Hostname() (string, error)

Try to get fully qualified hostname for current machine.

It tries to mimic how `hostname -f` works, so except for few edge cases you should get the same result from both. One thing that needs to be mentioned is that it does not guarantee that you get back fqdn. There is no way to do that and `hostname -f` can also return non-fqdn hostname if your /etc/hosts is malformed.

It checks few sources in this order:

  1. hosts file It parses hosts file if present and readable and returns first canonical hostname that also references your hostname. See hosts(5) for more details.
  2. dns lookup If lookup in hosts file fails, it tries to ask dns.

Types

This section is empty.

Jump to

Keyboard shortcuts

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