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.
10
// Hostname returns the host name reported by the kernel.
11
func Hostname() (name string, err Error) {
12
f, err := Open("/proc/sys/kernel/hostname", O_RDONLY, 0)
18
var buf [512]byte // Enough for a DNS name.
19
n, err := f.Read(buf[0:])
24
if n > 0 && buf[n-1] == '\n' {
27
return string(buf[0:n]), nil