Source file src/pkg/os/sys_bsd.go
1 // Copyright 2009 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // os code shared between *BSD systems including OS X (Darwin) 6 // and FreeBSD. 7 8 package os 9 10 import "syscall" 11 12 func Hostname() (name string, err Error) { 13 var errno int 14 name, errno = syscall.Sysctl("kern.hostname") 15 if errno != 0 { 16 return "", NewSyscallError("sysctl kern.hostname", errno) 17 } 18 return name, nil 19 }