summaryrefslogtreecommitdiff
path: root/hostname_linux.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-03-22 05:22:04 -0500
committerJeff Carr <[email protected]>2025-03-22 05:22:04 -0500
commitb2ed4102763421924b29ab4bb6be1a1e5b4b9647 (patch)
tree679db085b742c1eb5b0f3fb75aac54507e993620 /hostname_linux.go
parent68127e4356d00604b454bfee002a7fda233fb773 (diff)
work on setting the hostname in the patchset
Diffstat (limited to 'hostname_linux.go')
-rw-r--r--hostname_linux.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/hostname_linux.go b/hostname_linux.go
new file mode 100644
index 0000000..4ab6dee
--- /dev/null
+++ b/hostname_linux.go
@@ -0,0 +1,22 @@
+package main
+
+import (
+ "fmt"
+ "os"
+ "syscall"
+)
+
+// GetFullHostname returns the hostname + domain name (if set).
+func getFullHostname() (string, error) {
+ host, err := os.Hostname()
+ if err != nil {
+ return "", fmt.Errorf("failed to get hostname: %w", err)
+ }
+
+ domain, err := getDomainName()
+ if err != nil || domain == "" {
+ return host, nil // fallback to short hostname
+ }
+
+ return fmt.Sprintf("%s.%s", host, domain), nil
+}