github.com/FenixAra/go@v0.0.0-20170127160404-96ea0918e670/src/os/sys_bsd.go (about)

     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  // +build darwin dragonfly freebsd nacl netbsd openbsd
     6  
     7  // os code shared between *BSD systems including OS X (Darwin)
     8  // and FreeBSD.
     9  
    10  package os
    11  
    12  import "syscall"
    13  
    14  func hostname() (name string, err error) {
    15  	name, err = syscall.Sysctl("kern.hostname")
    16  	if err != nil {
    17  		return "", NewSyscallError("sysctl kern.hostname", err)
    18  	}
    19  	return name, nil
    20  }