17 lines
319 B
Go
17 lines
319 B
Go
package names
|
|
|
|
import (
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
// Hostname returns this hosts hostname, converting to lowercase so that
|
|
// it is valid for use in the Calico API.
|
|
func Hostname() (string, error) {
|
|
if h, err := os.Hostname(); err != nil {
|
|
return "", err
|
|
} else {
|
|
return strings.ToLower(strings.TrimSpace(h)), nil
|
|
}
|
|
}
|