2010-12-02 20:34:57 -08:00
|
|
|
// Copyright 2009 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2021-07-30 14:28:58 -07:00
|
|
|
//go:build darwin || dragonfly || freebsd || (js && wasm) || netbsd || openbsd
|
2010-12-02 20:34:57 -08:00
|
|
|
|
|
|
|
package os
|
|
|
|
|
|
|
|
import "syscall"
|
|
|
|
|
2012-01-25 13:54:22 -08:00
|
|
|
func hostname() (name string, err error) {
|
2011-12-12 15:40:51 -08:00
|
|
|
name, err = syscall.Sysctl("kern.hostname")
|
|
|
|
if err != nil {
|
|
|
|
return "", NewSyscallError("sysctl kern.hostname", err)
|
2010-12-02 20:34:57 -08:00
|
|
|
}
|
|
|
|
return name, nil
|
|
|
|
}
|