Files
kubesphere/vendor/github.com/projectcalico/libcalico-go/lib/names/hostname.go
2019-08-17 15:34:02 +08:00

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
}
}