fqdn

package
v1.0.75 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: MIT Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFqdnNotFound = errFqdnNotFound{}

Error for cases when we could not found fqdn for whatever reason.

View Source
var ErrHostnameFailed = errHostnameFailed{}

Error for cases when os.Hostname() fails.

Functions

func Get deprecated

func Get() string

Get Fully Qualified Domain Name returns "unknown" or hostname in case of error

Deprecated:

This function has bad API, works poorly and is replace by
Hostname. Please please do not use it. It *will* be removed
in the next version.

func Hostname

func Hostname() (string, error)

Hostname 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 fucked up.

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.

If none of steps above succeeds, ErrFqdnNotFound is returned as error. You will probably want to just use output from os.Hostname() at that point.

Types

This section is empty.

Jump to

Keyboard shortcuts

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