diff options
Diffstat (limited to 'src/pkg/os')
-rw-r--r-- | src/pkg/os/error.go | 20 | ||||
-rw-r--r-- | src/pkg/os/exec.go | 8 | ||||
-rw-r--r-- | src/pkg/os/file.go | 12 | ||||
-rw-r--r-- | src/pkg/os/proc.go | 20 | ||||
-rw-r--r-- | src/pkg/os/sys_nacl.go | 4 | ||||
-rw-r--r-- | src/pkg/os/types.go | 36 |
6 files changed, 25 insertions, 75 deletions
diff --git a/src/pkg/os/error.go b/src/pkg/os/error.go index 809116cff..6bbf5371e 100644 --- a/src/pkg/os/error.go +++ b/src/pkg/os/error.go @@ -15,26 +15,20 @@ type Error interface { // Error. type ErrorString string -func (e ErrorString) String() string { - return string(e); -} +func (e ErrorString) String() string { return string(e) } // Note: If the name of the function NewError changes, // pkg/go/doc/doc.go should be adjusted since it hardwires // this name in a heuristic. // NewError converts s to an ErrorString, which satisfies the Error interface. -func NewError(s string) Error { - return ErrorString(s); -} +func NewError(s string) Error { return ErrorString(s) } // Errno is the Unix error number. Names such as EINVAL are simple // wrappers to convert the error number into an Error. type Errno int64 -func (e Errno) String() string { - return syscall.Errstr(int(e)); -} +func (e Errno) String() string { return syscall.Errstr(int(e)) } // Commonly known Unix errors. var ( @@ -84,9 +78,7 @@ type PathError struct { Error Error; } -func (e *PathError) String() string { - return e.Op + " " + e.Path + ": " + e.Error.String(); -} +func (e *PathError) String() string { return e.Op + " " + e.Path + ": " + e.Error.String() } // SyscallError records an error from a specific system call. type SyscallError struct { @@ -94,9 +86,7 @@ type SyscallError struct { Errno Errno; } -func (e *SyscallError) String() string { - return e.Syscall + ": " + e.Errno.String(); -} +func (e *SyscallError) String() string { return e.Syscall + ": " + e.Errno.String() } // Note: If the name of the function NewSyscallError changes, // pkg/go/doc/doc.go should be adjusted since it hardwires diff --git a/src/pkg/os/exec.go b/src/pkg/os/exec.go index 79d25b2dc..a279bf428 100644 --- a/src/pkg/os/exec.go +++ b/src/pkg/os/exec.go @@ -145,11 +145,7 @@ func (w Waitmsg) String() string { } // Getpid returns the process id of the caller. -func Getpid() int { - return syscall.Getpid(); -} +func Getpid() int { return syscall.Getpid() } // Getppid returns the process id of the caller's parent. -func Getppid() int { - return syscall.Getppid(); -} +func Getppid() int { return syscall.Getppid() } diff --git a/src/pkg/os/file.go b/src/pkg/os/file.go index 578bc2e9e..0afdca39c 100644 --- a/src/pkg/os/file.go +++ b/src/pkg/os/file.go @@ -26,14 +26,10 @@ type File struct { } // Fd returns the integer Unix file descriptor referencing the open file. -func (file *File) Fd() int { - return file.fd; -} +func (file *File) Fd() int { return file.fd } // Name returns the name of the file as presented to Open. -func (file *File) Name() string { - return file.name; -} +func (file *File) Name() string { return file.name } // NewFile returns a new File with the given file descriptor and name. func NewFile(fd int, name string) *File { @@ -102,9 +98,7 @@ func (file *File) Close() Error { type eofError int -func (eofError) String() string { - return "EOF"; -} +func (eofError) String() string { return "EOF" } // EOF is the Error returned by Read when no more input is available. // Functions should return EOF only to signal a graceful end of input. diff --git a/src/pkg/os/proc.go b/src/pkg/os/proc.go index 0dd295edf..e780cfc9a 100644 --- a/src/pkg/os/proc.go +++ b/src/pkg/os/proc.go @@ -13,24 +13,16 @@ var Envs []string // provided by runtime // Getuid returns the numeric user id of the caller. -func Getuid() int { - return syscall.Getuid(); -} +func Getuid() int { return syscall.Getuid() } // Geteuid returns the numeric effective user id of the caller. -func Geteuid() int { - return syscall.Geteuid(); -} +func Geteuid() int { return syscall.Geteuid() } // Getgid returns the numeric group id of the caller. -func Getgid() int { - return syscall.Getgid(); -} +func Getgid() int { return syscall.Getgid() } // Getegid returns the numeric effective group id of the caller. -func Getegid() int { - return syscall.Getegid(); -} +func Getegid() int { return syscall.Getegid() } // Getgroups returns a list of the numeric ids of groups that the caller belongs to. func Getgroups() ([]int, Error) { @@ -40,6 +32,4 @@ func Getgroups() ([]int, Error) { // Exit causes the current program to exit with the given status code. // Conventionally, code zero indicates success, non-zero an error. -func Exit(code int) { - syscall.Exit(code); -} +func Exit(code int) { syscall.Exit(code) } diff --git a/src/pkg/os/sys_nacl.go b/src/pkg/os/sys_nacl.go index 0bea28095..51694a046 100644 --- a/src/pkg/os/sys_nacl.go +++ b/src/pkg/os/sys_nacl.go @@ -4,6 +4,4 @@ package os -func Hostname() (name string, err Error) { - return "nacl", nil; -} +func Hostname() (name string, err Error) { return "nacl", nil } diff --git a/src/pkg/os/types.go b/src/pkg/os/types.go index 7ed547c9b..ec3b4e11b 100644 --- a/src/pkg/os/types.go +++ b/src/pkg/os/types.go @@ -10,9 +10,7 @@ import "syscall" // OS-specific routines in this directory convert the OS-local versions to these. // Getpagesize returns the underlying system's memory page size. -func Getpagesize() int { - return syscall.Getpagesize(); -} +func Getpagesize() int { return syscall.Getpagesize() } // A Dir describes a file and is returned by Stat, Fstat, and Lstat type Dir struct { @@ -34,41 +32,25 @@ type Dir struct { } // IsFifo reports whether the Dir describes a FIFO file. -func (dir *Dir) IsFifo() bool { - return (dir.Mode & syscall.S_IFMT) == syscall.S_IFIFO; -} +func (dir *Dir) IsFifo() bool { return (dir.Mode & syscall.S_IFMT) == syscall.S_IFIFO } // IsChar reports whether the Dir describes a character special file. -func (dir *Dir) IsChar() bool { - return (dir.Mode & syscall.S_IFMT) == syscall.S_IFCHR; -} +func (dir *Dir) IsChar() bool { return (dir.Mode & syscall.S_IFMT) == syscall.S_IFCHR } // IsDirectory reports whether the Dir describes a directory. -func (dir *Dir) IsDirectory() bool { - return (dir.Mode & syscall.S_IFMT) == syscall.S_IFDIR; -} +func (dir *Dir) IsDirectory() bool { return (dir.Mode & syscall.S_IFMT) == syscall.S_IFDIR } // IsBlock reports whether the Dir describes a block special file. -func (dir *Dir) IsBlock() bool { - return (dir.Mode & syscall.S_IFMT) == syscall.S_IFBLK; -} +func (dir *Dir) IsBlock() bool { return (dir.Mode & syscall.S_IFMT) == syscall.S_IFBLK } // IsRegular reports whether the Dir describes a regular file. -func (dir *Dir) IsRegular() bool { - return (dir.Mode & syscall.S_IFMT) == syscall.S_IFREG; -} +func (dir *Dir) IsRegular() bool { return (dir.Mode & syscall.S_IFMT) == syscall.S_IFREG } // IsSymlink reports whether the Dir describes a symbolic link. -func (dir *Dir) IsSymlink() bool { - return (dir.Mode & syscall.S_IFMT) == syscall.S_IFLNK; -} +func (dir *Dir) IsSymlink() bool { return (dir.Mode & syscall.S_IFMT) == syscall.S_IFLNK } // IsSocket reports whether the Dir describes a socket. -func (dir *Dir) IsSocket() bool { - return (dir.Mode & syscall.S_IFMT) == syscall.S_IFSOCK; -} +func (dir *Dir) IsSocket() bool { return (dir.Mode & syscall.S_IFMT) == syscall.S_IFSOCK } // Permission returns the file permission bits. -func (dir *Dir) Permission() int { - return int(dir.Mode & 0777); -} +func (dir *Dir) Permission() int { return int(dir.Mode & 0777) } |