2009-06-29 13:44:46 -07: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.
|
|
|
|
|
|
|
|
|
|
// Darwin-specific
|
|
|
|
|
|
|
|
|
|
package os
|
|
|
|
|
|
2009-08-12 13:18:37 -07:00
|
|
|
import "syscall"
|
2009-06-29 13:44:46 -07:00
|
|
|
|
2009-08-10 22:02:51 -07:00
|
|
|
func Hostname() (name string, err Error) {
|
2009-12-15 15:40:16 -08:00
|
|
|
var errno int
|
|
|
|
|
name, errno = syscall.Sysctl("kern.hostname")
|
2009-06-29 13:44:46 -07:00
|
|
|
if errno != 0 {
|
2009-11-09 12:07:39 -08:00
|
|
|
return "", NewSyscallError("sysctl kern.hostname", errno)
|
2009-06-29 13:44:46 -07:00
|
|
|
}
|
2009-12-15 15:40:16 -08:00
|
|
|
return name, nil
|
2009-06-29 13:44:46 -07:00
|
|
|
}
|