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 ¶
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:
- 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.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.