21 lines
366 B
Go
21 lines
366 B
Go
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
|
|
}
|