2009-06-29 14:44:46 -06: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.
|
|
|
|
|
2010-04-27 00:01:31 -06:00
|
|
|
// os code shared between *BSD systems including OS X (Darwin)
|
|
|
|
// and FreeBSD.
|
2009-06-29 14:44:46 -06:00
|
|
|
|
|
|
|
package os
|
|
|
|
|
2009-08-12 14:18:37 -06:00
|
|
|
import "syscall"
|
2009-06-29 14:44:46 -06:00
|
|
|
|
2009-08-10 23:02:51 -06:00
|
|
|
func Hostname() (name string, err Error) {
|
2009-12-15 16:40:16 -07:00
|
|
|
var errno int
|
|
|
|
name, errno = syscall.Sysctl("kern.hostname")
|
2009-06-29 14:44:46 -06:00
|
|
|
if errno != 0 {
|
2009-11-09 13:07:39 -07:00
|
|
|
return "", NewSyscallError("sysctl kern.hostname", errno)
|
2009-06-29 14:44:46 -06:00
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return name, nil
|
2009-06-29 14:44:46 -06:00
|
|
|
}
|