From 6a205dfa4e3f217e3317509911ddc812a8ef49f6 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 31 Aug 2025 12:17:05 -0500 Subject: wasn't compiling on the mac --- get.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'get.go') diff --git a/get.go b/get.go index 0395e98..ece18ed 100644 --- a/get.go +++ b/get.go @@ -1,9 +1,17 @@ package hostname +import "fmt" + // returns the hostname // hostname is always set to the best effort // error is set if hostname isn't real func Get() (string, error) { hostname, err := osGetHostname() + if hostname == "" { + if err == nil { + err = fmt.Errorf("your machines' hostname is not set") + } + hostname = "unconfigured.hostname" + } return hostname, err } -- cgit v1.2.3