2010-12-03 05:34:57 +01: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.
|
|
|
|
|
2013-11-06 20:49:01 +01:00
|
|
|
// +build darwin dragonfly freebsd netbsd openbsd
|
2011-10-27 01:57:58 +02:00
|
|
|
|
2010-12-03 05:34:57 +01:00
|
|
|
// os code shared between *BSD systems including OS X (Darwin)
|
|
|
|
// and FreeBSD.
|
|
|
|
|
|
|
|
package os
|
|
|
|
|
|
|
|
import "syscall"
|
|
|
|
|
2012-01-25 22:54:22 +01:00
|
|
|
func hostname() (name string, err error) {
|
2011-12-13 00:40:51 +01:00
|
|
|
name, err = syscall.Sysctl("kern.hostname")
|
|
|
|
if err != nil {
|
|
|
|
return "", NewSyscallError("sysctl kern.hostname", err)
|
2010-12-03 05:34:57 +01:00
|
|
|
}
|
|
|
|
return name, nil
|
|
|
|
}
|