summaryrefslogtreecommitdiff
path: root/get.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-08-31 12:17:05 -0500
committerJeff Carr <[email protected]>2025-08-31 12:17:05 -0500
commit6a205dfa4e3f217e3317509911ddc812a8ef49f6 (patch)
tree9f3e340ed0894d98a9df26c522d75f02b7369302 /get.go
parentdf3dbcbc7e5bdcf526c109dbdb55a2553d39bb3a (diff)
wasn't compiling on the macv0.0.3
Diffstat (limited to 'get.go')
-rw-r--r--get.go8
1 files changed, 8 insertions, 0 deletions
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
}