hostname.go 268 B

123456789101112131415
  1. package hostname
  2. import "os"
  3. // Get returns the hostname of this host.
  4. func Get() string {
  5. if hostname := os.Getenv("SCOPE_HOSTNAME"); hostname != "" {
  6. return hostname
  7. }
  8. hostname, err := os.Hostname()
  9. if err != nil {
  10. return "(unknown)"
  11. }
  12. return hostname
  13. }