Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrFqdnNotFound = errFqdnNotFound{}
Error for cases when we could not found fqdn for whatever reason.
var ErrHostnameFailed = errHostnameFailed{}
Error for cases when os.Hostname() fails.
Functions ¶
func FqdnHostname ¶
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:
- 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.
- 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.