Hostname returns the hostname of the machine, lowercased, with any trailing domain suffix stripped. It is cached after the first call. If the hostname cannot be determined, for any reason, localhost will be returned instead.
()
| 17 | // If the hostname cannot be determined, for any reason, |
| 18 | // localhost will be returned instead. |
| 19 | func Hostname() string { |
| 20 | hostnameOnce.Do(func() { hostname = getHostname() }) |
| 21 | return hostname |
| 22 | } |
| 23 | |
| 24 | func getHostname() string { |
| 25 | h, err := os.Hostname() |
no test coverage detected