This commit is contained in:
Søren Rasmussen 2024-08-29 14:10:47 +02:00
parent ff79e2a767
commit 064b401da1
Signed by: snr
SSH key fingerprint: SHA256:wwGTdUDKh+zxCdbhOjJ5jt5/zF36kbg44gQPN6D9t1w

21
host/host.go Normal file
View file

@ -0,0 +1,21 @@
package host
import (
"context"
"os/exec"
)
// GetFQDN returns the fully qualified hostname of the current host
func GetFQDN(ctx context.Context) (string, error) {
cmd := exec.CommandContext(ctx, "hostname", "--fqdn")
if err := cmd.Run(); err != nil {
return "", err
}
b, err := cmd.Output()
if err != nil {
return "", err
}
return string(b), nil
}