Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(7)

Side by Side Diff: src/pkg/os/sys_linux.go

Issue 180049: code review 180049: 1) Change default gofmt default settings for (Closed)
Patch Set: code review 180049: 1) Change default gofmt default settings for Created 15 years, 3 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/pkg/os/sys_freebsd.go ('k') | src/pkg/os/sys_nacl.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // Linux-specific 5 // Linux-specific
6 6
7 package os 7 package os
8 8
9 9
10 // Hostname returns the host name reported by the kernel. 10 // Hostname returns the host name reported by the kernel.
11 func Hostname() (name string, err Error) { 11 func Hostname() (name string, err Error) {
12 » f, err := Open("/proc/sys/kernel/hostname", O_RDONLY, 0); 12 » f, err := Open("/proc/sys/kernel/hostname", O_RDONLY, 0)
13 if err != nil { 13 if err != nil {
14 return "", err 14 return "", err
15 } 15 }
16 » defer f.Close(); 16 » defer f.Close()
17 17
18 » var buf [512]byte;» // Enough for a DNS name. 18 » var buf [512]byte // Enough for a DNS name.
19 » n, err := f.Read(&buf); 19 » n, err := f.Read(&buf)
20 if err != nil { 20 if err != nil {
21 return "", err 21 return "", err
22 } 22 }
23 23
24 if n > 0 && buf[n-1] == '\n' { 24 if n > 0 && buf[n-1] == '\n' {
25 n-- 25 n--
26 } 26 }
27 » return string(buf[0:n]), nil; 27 » return string(buf[0:n]), nil
28 } 28 }
OLDNEW
« no previous file with comments | « src/pkg/os/sys_freebsd.go ('k') | src/pkg/os/sys_nacl.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b