summaryrefslogtreecommitdiff
path: root/src/pkg/os
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2009-10-06 19:40:35 -0700
committerRuss Cox <rsc@golang.org>2009-10-06 19:40:35 -0700
commitdb62e99a735a036afda2098f1a721fe8dbf6ce76 (patch)
tree0659cc93b73ec28c8a1b46725f0c3d540bda5daf /src/pkg/os
parent184ae37561c4cfc3b2351312d3793c5788f67ae8 (diff)
downloadgolang-db62e99a735a036afda2098f1a721fe8dbf6ce76.tar.gz
apply gofmt to malloc math once os
R=gri DELTA=566 (4 added, 14 deleted, 548 changed) OCL=35410 CL=35419
Diffstat (limited to 'src/pkg/os')
-rw-r--r--src/pkg/os/dir_darwin_386.go20
-rw-r--r--src/pkg/os/dir_darwin_amd64.go20
-rw-r--r--src/pkg/os/dir_linux_386.go20
-rw-r--r--src/pkg/os/dir_linux_amd64.go20
-rw-r--r--src/pkg/os/dir_linux_arm.go20
-rw-r--r--src/pkg/os/dir_nacl_386.go20
-rw-r--r--src/pkg/os/env.go12
-rw-r--r--src/pkg/os/error.go94
-rw-r--r--src/pkg/os/exec.go28
-rw-r--r--src/pkg/os/file.go94
-rw-r--r--src/pkg/os/getwd.go16
-rw-r--r--src/pkg/os/os_test.go88
-rw-r--r--src/pkg/os/path.go4
-rw-r--r--src/pkg/os/path_test.go18
-rw-r--r--src/pkg/os/proc.go5
-rw-r--r--src/pkg/os/stat_darwin_386.go6
-rw-r--r--src/pkg/os/stat_darwin_amd64.go6
-rw-r--r--src/pkg/os/stat_linux_386.go6
-rw-r--r--src/pkg/os/stat_linux_amd64.go6
-rw-r--r--src/pkg/os/stat_linux_arm.go6
-rw-r--r--src/pkg/os/stat_nacl_386.go12
-rw-r--r--src/pkg/os/time.go3
-rw-r--r--src/pkg/os/types.go45
23 files changed, 283 insertions, 286 deletions
diff --git a/src/pkg/os/dir_darwin_386.go b/src/pkg/os/dir_darwin_386.go
index 0131ab1b0..c207a19fd 100644
--- a/src/pkg/os/dir_darwin_386.go
+++ b/src/pkg/os/dir_darwin_386.go
@@ -10,7 +10,7 @@ import (
)
const (
- blockSize = 4096 // TODO(r): use statfs
+ blockSize = 4096; // TODO(r): use statfs
)
// Readdirnames reads the contents of the directory associated with file and
@@ -29,7 +29,7 @@ func (file *File) Readdirnames(count int) (names []string, err Error) {
d := file.dirinfo;
size := count;
if size < 0 {
- size = 100
+ size = 100;
}
names = make([]string, 0, size); // Empty with room to grow.
for count != 0 {
@@ -44,7 +44,7 @@ func (file *File) Readdirnames(count int) (names []string, err Error) {
return names, NewSyscallError("getdirentries", errno);
}
if d.nbuf <= 0 {
- break // EOF
+ break; // EOF
}
}
// Drain the buffer
@@ -52,28 +52,28 @@ func (file *File) Readdirnames(count int) (names []string, err Error) {
dirent := (*syscall.Dirent)(unsafe.Pointer(&d.buf[d.bufp]));
if dirent.Reclen == 0 {
d.bufp = d.nbuf;
- break
+ break;
}
d.bufp += int(dirent.Reclen);
if dirent.Ino == 0 { // File absent in directory.
- continue
+ continue;
}
bytes := (*[len(dirent.Name)]byte)(unsafe.Pointer(&dirent.Name[0]));
- var name = string(bytes[0:dirent.Namlen]);
+ var name = string(bytes[0 : dirent.Namlen]);
if name == "." || name == ".." { // Useless names
- continue
+ continue;
}
count--;
if len(names) == cap(names) {
nnames := make([]string, len(names), 2*len(names));
for i := 0; i < len(names); i++ {
- nnames[i] = names[i]
+ nnames[i] = names[i];
}
names = nnames;
}
- names = names[0:len(names)+1];
+ names = names[0 : len(names)+1];
names[len(names)-1] = name;
}
}
- return names, nil
+ return names, nil;
}
diff --git a/src/pkg/os/dir_darwin_amd64.go b/src/pkg/os/dir_darwin_amd64.go
index 7701b7d0d..d42c59e91 100644
--- a/src/pkg/os/dir_darwin_amd64.go
+++ b/src/pkg/os/dir_darwin_amd64.go
@@ -10,7 +10,7 @@ import (
)
const (
- blockSize = 4096 // TODO(r): use statfs
+ blockSize = 4096; // TODO(r): use statfs
)
func (file *File) Readdirnames(count int) (names []string, err Error) {
@@ -24,7 +24,7 @@ func (file *File) Readdirnames(count int) (names []string, err Error) {
d := file.dirinfo;
size := count;
if size < 0 {
- size = 100
+ size = 100;
}
names = make([]string, 0, size); // Empty with room to grow.
for count != 0 {
@@ -39,7 +39,7 @@ func (file *File) Readdirnames(count int) (names []string, err Error) {
return names, NewSyscallError("getdirentries", errno);
}
if d.nbuf <= 0 {
- break // EOF
+ break; // EOF
}
}
// Drain the buffer
@@ -47,28 +47,28 @@ func (file *File) Readdirnames(count int) (names []string, err Error) {
dirent := (*syscall.Dirent)(unsafe.Pointer(&d.buf[d.bufp]));
if dirent.Reclen == 0 {
d.bufp = d.nbuf;
- break
+ break;
}
d.bufp += int(dirent.Reclen);
if dirent.Ino == 0 { // File absent in directory.
- continue
+ continue;
}
bytes := (*[len(dirent.Name)]byte)(unsafe.Pointer(&dirent.Name[0]));
- var name = string(bytes[0:dirent.Namlen]);
+ var name = string(bytes[0 : dirent.Namlen]);
if name == "." || name == ".." { // Useless names
- continue
+ continue;
}
count--;
if len(names) == cap(names) {
nnames := make([]string, len(names), 2*len(names));
for i := 0; i < len(names); i++ {
- nnames[i] = names[i]
+ nnames[i] = names[i];
}
names = nnames;
}
- names = names[0:len(names)+1];
+ names = names[0 : len(names)+1];
names[len(names)-1] = name;
}
}
- return names, nil
+ return names, nil;
}
diff --git a/src/pkg/os/dir_linux_386.go b/src/pkg/os/dir_linux_386.go
index 0e70f0ba0..64db8827b 100644
--- a/src/pkg/os/dir_linux_386.go
+++ b/src/pkg/os/dir_linux_386.go
@@ -14,16 +14,16 @@ import (
)
const (
- blockSize = 4096 // TODO(r): use statfs
+ blockSize = 4096; // TODO(r): use statfs
)
func clen(n []byte) int {
for i := 0; i < len(n); i++ {
if n[i] == 0 {
- return i
+ return i;
}
}
- return len(n)
+ return len(n);
}
func (file *File) Readdirnames(count int) (names []string, err Error) {
@@ -37,7 +37,7 @@ func (file *File) Readdirnames(count int) (names []string, err Error) {
d := file.dirinfo;
size := count;
if size < 0 {
- size = 100
+ size = 100;
}
names = make([]string, 0, size); // Empty with room to grow.
for count != 0 {
@@ -46,10 +46,10 @@ func (file *File) Readdirnames(count int) (names []string, err Error) {
var errno int;
d.nbuf, errno = syscall.Getdents(file.fd, d.buf);
if errno != 0 {
- return names, NewSyscallError("getdents", errno)
+ return names, NewSyscallError("getdents", errno);
}
if d.nbuf <= 0 {
- break // EOF
+ break; // EOF
}
d.bufp = 0;
}
@@ -58,22 +58,22 @@ func (file *File) Readdirnames(count int) (names []string, err Error) {
dirent := (*syscall.Dirent)(unsafe.Pointer(&d.buf[d.bufp]));
d.bufp += int(dirent.Reclen);
if dirent.Ino == 0 { // File absent in directory.
- continue
+ continue;
}
bytes := (*[len(dirent.Name)]byte)(unsafe.Pointer(&dirent.Name[0]));
var name = string(bytes[0:clen(bytes)]);
if name == "." || name == ".." { // Useless names
- continue
+ continue;
}
count--;
if len(names) == cap(names) {
nnames := make([]string, len(names), 2*len(names));
for i := 0; i < len(names); i++ {
- nnames[i] = names[i]
+ nnames[i] = names[i];
}
names = nnames;
}
- names = names[0:len(names)+1];
+ names = names[0 : len(names)+1];
names[len(names)-1] = name;
}
}
diff --git a/src/pkg/os/dir_linux_amd64.go b/src/pkg/os/dir_linux_amd64.go
index 8bd29b27c..d6e77016c 100644
--- a/src/pkg/os/dir_linux_amd64.go
+++ b/src/pkg/os/dir_linux_amd64.go
@@ -10,16 +10,16 @@ import (
)
const (
- blockSize = 4096 // TODO(r): use statfs
+ blockSize = 4096; // TODO(r): use statfs
)
func clen(n []byte) int {
for i := 0; i < len(n); i++ {
if n[i] == 0 {
- return i
+ return i;
}
}
- return len(n)
+ return len(n);
}
func (file *File) Readdirnames(count int) (names []string, err Error) {
@@ -33,7 +33,7 @@ func (file *File) Readdirnames(count int) (names []string, err Error) {
d := file.dirinfo;
size := count;
if size < 0 {
- size = 100
+ size = 100;
}
names = make([]string, 0, size); // Empty with room to grow.
for count != 0 {
@@ -42,10 +42,10 @@ func (file *File) Readdirnames(count int) (names []string, err Error) {
var errno int;
d.nbuf, errno = syscall.Getdents(file.fd, d.buf);
if errno != 0 {
- return names, NewSyscallError("getdents", errno)
+ return names, NewSyscallError("getdents", errno);
}
if d.nbuf <= 0 {
- break // EOF
+ break; // EOF
}
d.bufp = 0;
}
@@ -54,22 +54,22 @@ func (file *File) Readdirnames(count int) (names []string, err Error) {
dirent := (*syscall.Dirent)(unsafe.Pointer(&d.buf[d.bufp]));
d.bufp += int(dirent.Reclen);
if dirent.Ino == 0 { // File absent in directory.
- continue
+ continue;
}
bytes := (*[len(dirent.Name)]byte)(unsafe.Pointer(&dirent.Name[0]));
var name = string(bytes[0:clen(bytes)]);
if name == "." || name == ".." { // Useless names
- continue
+ continue;
}
count--;
if len(names) == cap(names) {
nnames := make([]string, len(names), 2*len(names));
for i := 0; i < len(names); i++ {
- nnames[i] = names[i]
+ nnames[i] = names[i];
}
names = nnames;
}
- names = names[0:len(names)+1];
+ names = names[0 : len(names)+1];
names[len(names)-1] = name;
}
}
diff --git a/src/pkg/os/dir_linux_arm.go b/src/pkg/os/dir_linux_arm.go
index 0e70f0ba0..64db8827b 100644
--- a/src/pkg/os/dir_linux_arm.go
+++ b/src/pkg/os/dir_linux_arm.go
@@ -14,16 +14,16 @@ import (
)
const (
- blockSize = 4096 // TODO(r): use statfs
+ blockSize = 4096; // TODO(r): use statfs
)
func clen(n []byte) int {
for i := 0; i < len(n); i++ {
if n[i] == 0 {
- return i
+ return i;
}
}
- return len(n)
+ return len(n);
}
func (file *File) Readdirnames(count int) (names []string, err Error) {
@@ -37,7 +37,7 @@ func (file *File) Readdirnames(count int) (names []string, err Error) {
d := file.dirinfo;
size := count;
if size < 0 {
- size = 100
+ size = 100;
}
names = make([]string, 0, size); // Empty with room to grow.
for count != 0 {
@@ -46,10 +46,10 @@ func (file *File) Readdirnames(count int) (names []string, err Error) {
var errno int;
d.nbuf, errno = syscall.Getdents(file.fd, d.buf);
if errno != 0 {
- return names, NewSyscallError("getdents", errno)
+ return names, NewSyscallError("getdents", errno);
}
if d.nbuf <= 0 {
- break // EOF
+ break; // EOF
}
d.bufp = 0;
}
@@ -58,22 +58,22 @@ func (file *File) Readdirnames(count int) (names []string, err Error) {
dirent := (*syscall.Dirent)(unsafe.Pointer(&d.buf[d.bufp]));
d.bufp += int(dirent.Reclen);
if dirent.Ino == 0 { // File absent in directory.
- continue
+ continue;
}
bytes := (*[len(dirent.Name)]byte)(unsafe.Pointer(&dirent.Name[0]));
var name = string(bytes[0:clen(bytes)]);
if name == "." || name == ".." { // Useless names
- continue
+ continue;
}
count--;
if len(names) == cap(names) {
nnames := make([]string, len(names), 2*len(names));
for i := 0; i < len(names); i++ {
- nnames[i] = names[i]
+ nnames[i] = names[i];
}
names = nnames;
}
- names = names[0:len(names)+1];
+ names = names[0 : len(names)+1];
names[len(names)-1] = name;
}
}
diff --git a/src/pkg/os/dir_nacl_386.go b/src/pkg/os/dir_nacl_386.go
index 90072d54d..97767ddc0 100644
--- a/src/pkg/os/dir_nacl_386.go
+++ b/src/pkg/os/dir_nacl_386.go
@@ -14,16 +14,16 @@ import (
)
const (
- blockSize = 4096 // TODO(r): use statfs
+ blockSize = 4096; // TODO(r): use statfs
)
func clen(n []byte) int {
for i := 0; i < len(n); i++ {
if n[i] == 0 {
- return i
+ return i;
}
}
- return len(n)
+ return len(n);
}
func (file *File) Readdirnames(count int) (names []string, err Error) {
@@ -37,7 +37,7 @@ func (file *File) Readdirnames(count int) (names []string, err Error) {
d := file.dirinfo;
size := count;
if size < 0 {
- size = 100
+ size = 100;
}
names = make([]string, 0, size); // Empty with room to grow.
for count != 0 {
@@ -46,10 +46,10 @@ func (file *File) Readdirnames(count int) (names []string, err Error) {
var errno int;
d.nbuf, errno = syscall.Getdents(file.fd, d.buf);
if errno != 0 {
- return names, NewSyscallError("getdents", errno)
+ return names, NewSyscallError("getdents", errno);
}
if d.nbuf <= 0 {
- break // EOF
+ break; // EOF
}
d.bufp = 0;
}
@@ -58,22 +58,22 @@ func (file *File) Readdirnames(count int) (names []string, err Error) {
dirent := (*syscall.Dirent)(unsafe.Pointer(&d.buf[d.bufp]));
d.bufp += int(dirent.Reclen);
if dirent.Ino == 0 { // File absent in directory.
- continue
+ continue;
}
bytes := (*[len(dirent.Name)]byte)(unsafe.Pointer(&dirent.Name[0]));
var name = string(bytes[0:clen(bytes)]);
if name == "." || name == ".." { // Useless names
- continue
+ continue;
}
count--;
if len(names) == cap(names) {
nnames := make([]string, len(names), 2*len(names));
for i := 0; i < len(names); i++ {
- nnames[i] = names[i]
+ nnames[i] = names[i];
}
names = nnames;
}
- names = names[0:len(names)+1];
+ names = names[0 : len(names)+1];
names[len(names)-1] = name;
}
}
diff --git a/src/pkg/os/env.go b/src/pkg/os/env.go
index 04d759128..3523f57e4 100644
--- a/src/pkg/os/env.go
+++ b/src/pkg/os/env.go
@@ -11,17 +11,17 @@ import (
)
// ENOENV is the Error indicating that an environment variable does not exist.
-var ENOENV = NewError("no such environment variable");
+var ENOENV = NewError("no such environment variable")
-var env map[string] string;
+var env map[string]string
func copyenv() {
- env = make(map[string] string);
+ env = make(map[string]string);
for _, s := range Envs {
for j := 0; j < len(s); j++ {
if s[j] == '=' {
- env[s[0:j]] = s[j+1:len(s)];
+ env[s[0:j]] = s[j+1 : len(s)];
break;
}
}
@@ -65,7 +65,7 @@ func Setenv(key, value string) Error {
// Clearenv deletes all environment variables.
func Clearenv() {
once.Do(copyenv); // prevent copyenv in Getenv/Setenv
- env = make(map[string] string);
+ env = make(map[string]string);
}
// Environ returns an array of strings representing the environment,
@@ -78,7 +78,7 @@ func Environ() []string {
// check i < len(a) for safety,
// in case env is changing underfoot.
if i < len(a) {
- a[i] = k + "=" + v;
+ a[i] = k+"="+v;
i++;
}
}
diff --git a/src/pkg/os/error.go b/src/pkg/os/error.go
index 5430a4b30..eca45dd26 100644
--- a/src/pkg/os/error.go
+++ b/src/pkg/os/error.go
@@ -8,73 +8,75 @@ import syscall "syscall"
// An Error can represent any printable error condition.
type Error interface {
- String() string
+ String() string;
}
// A helper type that can be embedded or wrapped to simplify satisfying
// Error.
type ErrorString string
+
func (e ErrorString) String() string {
- return string(e)
+ return string(e);
}
// NewError converts s to an ErrorString, which satisfies the Error interface.
func NewError(s string) Error {
- return ErrorString(s)
+ 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))
+ return syscall.Errstr(int(e));
}
// Commonly known Unix errors.
var (
- EPERM Error = Errno(syscall.EPERM);
- ENOENT Error = Errno(syscall.ENOENT);
- ESRCH Error = Errno(syscall.ESRCH);
- EINTR Error = Errno(syscall.EINTR);
- EIO Error = Errno(syscall.EIO);
- ENXIO Error = Errno(syscall.ENXIO);
- E2BIG Error = Errno(syscall.E2BIG);
- ENOEXEC Error = Errno(syscall.ENOEXEC);
- EBADF Error = Errno(syscall.EBADF);
- ECHILD Error = Errno(syscall.ECHILD);
- EDEADLK Error = Errno(syscall.EDEADLK);
- ENOMEM Error = Errno(syscall.ENOMEM);
- EACCES Error = Errno(syscall.EACCES);
- EFAULT Error = Errno(syscall.EFAULT);
- EBUSY Error = Errno(syscall.EBUSY);
- EEXIST Error = Errno(syscall.EEXIST);
- EXDEV Error = Errno(syscall.EXDEV);
- ENODEV Error = Errno(syscall.ENODEV);
- ENOTDIR Error = Errno(syscall.ENOTDIR);
- EISDIR Error = Errno(syscall.EISDIR);
- EINVAL Error = Errno(syscall.EINVAL);
- ENFILE Error = Errno(syscall.ENFILE);
- EMFILE Error = Errno(syscall.EMFILE);
- ENOTTY Error = Errno(syscall.ENOTTY);
- EFBIG Error = Errno(syscall.EFBIG);
- ENOSPC Error = Errno(syscall.ENOSPC);
- ESPIPE Error = Errno(syscall.ESPIPE);
- EROFS Error = Errno(syscall.EROFS);
- EMLINK Error = Errno(syscall.EMLINK);
- EPIPE Error = Errno(syscall.EPIPE);
- EAGAIN Error = Errno(syscall.EAGAIN);
- EDOM Error = Errno(syscall.EDOM);
- ERANGE Error = Errno(syscall.ERANGE);
- EADDRINUSE Error = Errno(syscall.EADDRINUSE);
- ECONNREFUSED Error = Errno(syscall.ECONNREFUSED);
- ENAMETOOLONG Error = Errno(syscall.ENAMETOOLONG);
+ EPERM Error = Errno(syscall.EPERM);
+ ENOENT Error = Errno(syscall.ENOENT);
+ ESRCH Error = Errno(syscall.ESRCH);
+ EINTR Error = Errno(syscall.EINTR);
+ EIO Error = Errno(syscall.EIO);
+ ENXIO Error = Errno(syscall.ENXIO);
+ E2BIG Error = Errno(syscall.E2BIG);
+ ENOEXEC Error = Errno(syscall.ENOEXEC);
+ EBADF Error = Errno(syscall.EBADF);
+ ECHILD Error = Errno(syscall.ECHILD);
+ EDEADLK Error = Errno(syscall.EDEADLK);
+ ENOMEM Error = Errno(syscall.ENOMEM);
+ EACCES Error = Errno(syscall.EACCES);
+ EFAULT Error = Errno(syscall.EFAULT);
+ EBUSY Error = Errno(syscall.EBUSY);
+ EEXIST Error = Errno(syscall.EEXIST);
+ EXDEV Error = Errno(syscall.EXDEV);
+ ENODEV Error = Errno(syscall.ENODEV);
+ ENOTDIR Error = Errno(syscall.ENOTDIR);
+ EISDIR Error = Errno(syscall.EISDIR);
+ EINVAL Error = Errno(syscall.EINVAL);
+ ENFILE Error = Errno(syscall.ENFILE);
+ EMFILE Error = Errno(syscall.EMFILE);
+ ENOTTY Error = Errno(syscall.ENOTTY);
+ EFBIG Error = Errno(syscall.EFBIG);
+ ENOSPC Error = Errno(syscall.ENOSPC);
+ ESPIPE Error = Errno(syscall.ESPIPE);
+ EROFS Error = Errno(syscall.EROFS);
+ EMLINK Error = Errno(syscall.EMLINK);
+ EPIPE Error = Errno(syscall.EPIPE);
+ EAGAIN Error = Errno(syscall.EAGAIN);
+ EDOM Error = Errno(syscall.EDOM);
+ ERANGE Error = Errno(syscall.ERANGE);
+ EADDRINUSE Error = Errno(syscall.EADDRINUSE);
+ ECONNREFUSED Error = Errno(syscall.ECONNREFUSED);
+ ENAMETOOLONG Error = Errno(syscall.ENAMETOOLONG);
)
// PathError records an error and the operation and file path that caused it.
type PathError struct {
- Op string;
- Path string;
- Error Error;
+ Op string;
+ Path string;
+ Error Error;
}
func (e *PathError) String() string {
@@ -83,8 +85,8 @@ func (e *PathError) String() string {
// SyscallError records an error from a specific system call.
type SyscallError struct {
- Syscall string;
- Errno Errno;
+ Syscall string;
+ Errno Errno;
}
func (e *SyscallError) String() string {
@@ -98,5 +100,5 @@ func NewSyscallError(syscall string, errno int) Error {
if errno == 0 {
return nil;
}
- return &SyscallError{syscall, Errno(errno)}
+ return &SyscallError{syscall, Errno(errno)};
}
diff --git a/src/pkg/os/exec.go b/src/pkg/os/exec.go
index c80ef43cb..ac158c8d3 100644
--- a/src/pkg/os/exec.go
+++ b/src/pkg/os/exec.go
@@ -15,9 +15,7 @@ import (
// descriptor 0 (standard input), fd[1] descriptor 1, and so on. A nil entry
// will cause the child to have no open file descriptor with that index.
// If dir is not empty, the child chdirs into the directory before execing the program.
-func ForkExec(argv0 string, argv []string, envv []string, dir string, fd []*File)
- (pid int, err Error)
-{
+func ForkExec(argv0 string, argv []string, envv []string, dir string, fd []*File) (pid int, err Error) {
// Create array of integer (system) fds.
intfd := make([]int, len(fd));
for i, f := range fd {
@@ -59,17 +57,17 @@ func Exec(argv0 string, argv []string, envv []string) Error {
// Waitmsg stores the information about an exited process as reported by Wait.
type Waitmsg struct {
- Pid int; // The process's id.
+ Pid int; // The process's id.
syscall.WaitStatus; // System-dependent status info.
- Rusage *syscall.Rusage; // System-dependent resource usage info.
+ Rusage *syscall.Rusage; // System-dependent resource usage info.
}
// Options for Wait.
const (
- WNOHANG = syscall.WNOHANG; // Don't wait if no process has exited.
- WSTOPPED = syscall.WSTOPPED; // If set, status of stopped subprocesses is also reported.
- WUNTRACED = WSTOPPED;
- WRUSAGE = 1<<20; // Record resource usage.
+ WNOHANG = syscall.WNOHANG; // Don't wait if no process has exited.
+ WSTOPPED = syscall.WSTOPPED; // If set, status of stopped subprocesses is also reported.
+ WUNTRACED = WSTOPPED;
+ WRUSAGE = 1<<20; // Record resource usage.
)
// WRUSAGE must not be too high a bit, to avoid clashing with Linux's
@@ -82,7 +80,7 @@ const (
func Wait(pid int, options int) (w *Waitmsg, err Error) {
var status syscall.WaitStatus;
var rusage *syscall.Rusage;
- if options & WRUSAGE != 0 {
+ if options&WRUSAGE != 0 {
rusage = new(syscall.Rusage);
options ^= WRUSAGE;
}
@@ -100,7 +98,7 @@ func Wait(pid int, options int) (w *Waitmsg, err Error) {
// Convert i to decimal string.
func itod(i int) string {
if i == 0 {
- return "0"
+ return "0";
}
u := uint64(i);
@@ -113,15 +111,15 @@ func itod(i int) string {
bp := len(b);
for ; u > 0; u /= 10 {
bp--;
- b[bp] = byte(u%10) + '0'
+ b[bp] = byte(u%10) + '0';
}
if i < 0 {
bp--;
- b[bp] = '-'
+ b[bp] = '-';
}
- return string(b[bp:len(b)])
+ return string(b[bp:len(b)]);
}
func (w Waitmsg) String() string {
@@ -141,7 +139,7 @@ func (w Waitmsg) String() string {
res = "continued";
}
if w.CoreDump() {
- res += " (core dumped)"
+ res += " (core dumped)";
}
return res;
}
diff --git a/src/pkg/os/file.go b/src/pkg/os/file.go
index c9c00788f..1f1d86f4e 100644
--- a/src/pkg/os/file.go
+++ b/src/pkg/os/file.go
@@ -19,52 +19,52 @@ type dirInfo struct {
// File represents an open file descriptor.
type File struct {
- fd int;
+ fd int;
name string;
dirinfo *dirInfo; // nil unless directory being read
- nepipe int; // number of consecutive EPIPE in Write
+ nepipe int; // number of consecutive EPIPE in Write
}
// Fd returns the integer Unix file descriptor referencing the open file.
func (file *File) Fd() int {
- return file.fd
+ return file.fd;
}
// Name returns the name of the file as presented to Open.
func (file *File) Name() string {
- return file.name
+ return file.name;
}
// NewFile returns a new File with the given file descriptor and name.
func NewFile(fd int, name string) *File {
if fd < 0 {
- return nil
+ return nil;
}
- return &File{fd, name, nil, 0}
+ return &File{fd, name, nil, 0};
}
// Stdin, Stdout, and Stderr are open Files pointing to the standard input,
// standard output, and standard error file descriptors.
var (
- Stdin = NewFile(0, "/dev/stdin");
- Stdout = NewFile(1, "/dev/stdout");
- Stderr = NewFile(2, "/dev/stderr");
+ Stdin = NewFile(0, "/dev/stdin");
+ Stdout = NewFile(1, "/dev/stdout");
+ Stderr = NewFile(2, "/dev/stderr");
)
// Flags to Open wrapping those of the underlying system. Not all flags
// may be implemented on a given system.
const (
- O_RDONLY = syscall.O_RDONLY; // open the file read-only.
- O_WRONLY = syscall.O_WRONLY; // open the file write-only.
- O_RDWR = syscall.O_RDWR; // open the file read-write.
- O_APPEND = syscall.O_APPEND; // open the file append-only.
- O_ASYNC = syscall.O_ASYNC; // generate a signal when I/O is available.
- O_CREAT = syscall.O_CREAT; // create a new file if none exists.
- O_NOCTTY = syscall.O_NOCTTY; // do not make file the controlling tty.
- O_NONBLOCK = syscall.O_NONBLOCK; // open in non-blocking mode.
- O_NDELAY = O_NONBLOCK; // synonym for O_NONBLOCK
- O_SYNC = syscall.O_SYNC; // open for synchronous I/O.
- O_TRUNC = syscall.O_TRUNC; // if possible, truncate file when opened.
+ O_RDONLY = syscall.O_RDONLY; // open the file read-only.
+ O_WRONLY = syscall.O_WRONLY; // open the file write-only.
+ O_RDWR = syscall.O_RDWR; // open the file read-write.
+ O_APPEND = syscall.O_APPEND; // open the file append-only.
+ O_ASYNC = syscall.O_ASYNC; // generate a signal when I/O is available.
+ O_CREAT = syscall.O_CREAT; // create a new file if none exists.
+ O_NOCTTY = syscall.O_NOCTTY; // do not make file the controlling tty.
+ O_NONBLOCK = syscall.O_NONBLOCK; // open in non-blocking mode.
+ O_NDELAY = O_NONBLOCK; // synonym for O_NONBLOCK
+ O_SYNC = syscall.O_SYNC; // open for synchronous I/O.
+ O_TRUNC = syscall.O_TRUNC; // if possible, truncate file when opened.
)
// Open opens the named file with specified flag (O_RDONLY etc.) and perm, (0666 etc.)
@@ -89,19 +89,20 @@ func Open(name string, flag int, perm int) (file *File, err Error) {
// It returns an Error, if any.
func (file *File) Close() Error {
if file == nil {
- return EINVAL
+ return EINVAL;
}
var err Error;
if e := syscall.Close(file.fd); e != 0 {
err = &PathError{"close", file.name, Errno(e)};
}
- file.fd = -1; // so it can't be closed again
+ file.fd = -1; // so it can't be closed again
return err;
}
type eofError int
+
func (eofError) String() string {
- return "EOF"
+ return "EOF";
}
// EOF is the Error returned by Read when no more input is available.
@@ -117,19 +118,19 @@ var EOF Error = eofError(0)
// TODO(r): Add Pread, Pwrite (maybe ReadAt, WriteAt).
func (file *File) Read(b []byte) (n int, err Error) {
if file == nil {
- return 0, EINVAL
+ return 0, EINVAL;
}
n, e := syscall.Read(file.fd, b);
if n < 0 {
n = 0;
}
if n == 0 && e == 0 {
- return 0, EOF
+ return 0, EOF;
}
if e != 0 {
err = &PathError{"read", file.name, Errno(e)};
}
- return n, err
+ return n, err;
}
// ReadAt reads len(b) bytes from the File starting at byte offset off.
@@ -158,11 +159,11 @@ func (file *File) ReadAt(b []byte, off int64) (n int, err Error) {
// Write returns a non-nil Error when n != len(b).
func (file *File) Write(b []byte) (n int, err Error) {
if file == nil {
- return 0, EINVAL
+ return 0, EINVAL;
}
n, e := syscall.Write(file.fd, b);
if n < 0 {
- n = 0
+ n = 0;
}
if e == syscall.EPIPE {
file.nepipe++;
@@ -175,7 +176,7 @@ func (file *File) Write(b []byte) (n int, err Error) {
if e != 0 {
err = &PathError{"write", file.name, Errno(e)};
}
- return n, err
+ return n, err;
}
// WriteAt writes len(b) bytes to the File starting at byte offset off.
@@ -210,17 +211,17 @@ func (file *File) Seek(offset int64, whence int) (ret int64, err Error) {
if e != 0 {
return 0, &PathError{"seek", file.name, Errno(e)};
}
- return r, nil
+ return r, nil;
}
// WriteString is like Write, but writes the contents of string s rather than
// an array of bytes.
func (file *File) WriteString(s string) (ret int, err Error) {
if file == nil {
- return 0, EINVAL
+ return 0, EINVAL;
}
b := syscall.StringByteSlice(s);
- b = b[0:len(b)-1];
+ b = b[0 : len(b)-1];
return file.Write(b);
}
@@ -240,7 +241,7 @@ func Pipe() (r *File, w *File, err Error) {
syscall.CloseOnExec(p[1]);
syscall.ForkLock.RUnlock();
- return NewFile(p[0], "|0"), NewFile(p[1], "|1"), nil
+ return NewFile(p[0], "|0"), NewFile(p[1], "|1"), nil;
}
// Mkdir creates a new directory with the specified name and permission bits.
@@ -271,7 +272,7 @@ func Stat(name string) (dir *Dir, err Error) {
statp = &stat;
}
}
- return dirFromStat(name, new(Dir), &lstat, statp), nil
+ return dirFromStat(name, new(Dir), &lstat, statp), nil;
}
// Stat returns the Dir structure describing file.
@@ -282,7 +283,7 @@ func (file *File) Stat() (dir *Dir, err Error) {
if e != 0 {
return nil, &PathError{"stat", file.name, Errno(e)};
}
- return dirFromStat(file.name, new(Dir), &stat, &stat), nil
+ return dirFromStat(file.name, new(Dir), &stat, &stat), nil;
}
// Lstat returns the Dir structure describing the named file and an error, if any.
@@ -294,7 +295,7 @@ func Lstat(name string) (dir *Dir, err Error) {
if e != 0 {
return nil, &PathError{"lstat", name, Errno(e)};
}
- return dirFromStat(name, new(Dir), &stat, &stat), nil
+ return dirFromStat(name, new(Dir), &stat, &stat), nil;
}
// Readdir reads the contents of the directory associated with file and
@@ -310,18 +311,18 @@ func (file *File) Readdir(count int) (dirs []Dir, err Error) {
dirname += "/";
names, err1 := file.Readdirnames(count);
if err1 != nil {
- return nil, err1
+ return nil, err1;
}
dirs = make([]Dir, len(names));
for i, filename := range names {
- dirp, err := Stat(dirname + filename);
- if dirp == nil || err != nil {
- dirs[i].Name = filename // rest is already zeroed out
+ dirp, err := Stat(dirname+filename);
+ if dirp == nil || err != nil {
+ dirs[i].Name = filename; // rest is already zeroed out
} else {
- dirs[i] = *dirp
+ dirs[i] = *dirp;
}
}
- return
+ return;
}
// Chdir changes the current working directory to the named directory.
@@ -374,10 +375,10 @@ func Remove(name string) Error {
// LinkError records an error during a link or symlink
// system call and the paths that caused it.
type LinkError struct {
- Op string;
- Old string;
- New string;
- Error Error;
+ Op string;
+ Old string;
+ New string;
+ Error Error;
}
func (e *LinkError) String() string {
@@ -479,4 +480,3 @@ func (f *File) Truncate(size int64) Error {
}
return nil;
}
-
diff --git a/src/pkg/os/getwd.go b/src/pkg/os/getwd.go
index e23f74df0..bb8637b2b 100644
--- a/src/pkg/os/getwd.go
+++ b/src/pkg/os/getwd.go
@@ -5,7 +5,7 @@
package os
import (
- "syscall"
+ "syscall";
)
// Getwd returns a rooted path name corresponding to the
@@ -27,11 +27,11 @@ func Getwd() (string, Error) {
// Clumsy but widespread kludge:
// if $PWD is set and matches ".", use it.
- pwd:= Getenv("PWD");
+ pwd := Getenv("PWD");
if len(pwd) > 0 && pwd[0] == '/' {
d, err := Stat(pwd);
if err == nil && d.Dev == dot.Dev && d.Ino == dot.Ino {
- return pwd, nil
+ return pwd, nil;
}
}
@@ -43,14 +43,14 @@ func Getwd() (string, Error) {
return "", err;
}
if root.Dev == dot.Dev && root.Ino == dot.Ino {
- return "/", nil
+ return "/", nil;
}
// General algorithm: find name in parent
// and then find name of parent. Each iteration
// adds /name to the beginning of pwd.
pwd = "";
- for parent := "..";; parent = "../" + parent {
+ for parent := ".."; ; parent = "../"+parent {
if len(parent) >= 1024 { // Sanity check
return "", ENAMETOOLONG;
}
@@ -66,9 +66,9 @@ func Getwd() (string, Error) {
return "", err;
}
for _, name := range names {
- d, _ := Lstat(parent + "/" + name);
+ d, _ := Lstat(parent+"/"+name);
if d.Dev == dot.Dev && d.Ino == dot.Ino {
- pwd = "/" + name + pwd;
+ pwd = "/"+name+pwd;
goto Found;
}
}
@@ -88,5 +88,5 @@ func Getwd() (string, Error) {
// Set up for next round.
dot = pd;
}
- return pwd, nil
+ return pwd, nil;
}
diff --git a/src/pkg/os/os_test.go b/src/pkg/os/os_test.go
index f711f73a5..2f77db20c 100644
--- a/src/pkg/os/os_test.go
+++ b/src/pkg/os/os_test.go
@@ -5,12 +5,12 @@
package os_test
import (
- "bytes";
- "fmt";
- "io";
- . "os";
- "strings";
- "testing";
+ "bytes";
+ "fmt";
+ "io";
+ . "os";
+ "strings";
+ "testing";
)
var dot = []string{
@@ -23,7 +23,7 @@ var dot = []string{
"time.go",
"types.go",
"stat_darwin_amd64.go",
- "stat_linux_amd64.go"
+ "stat_linux_amd64.go",
}
var etc = []string{
@@ -44,13 +44,13 @@ func size(name string, t *testing.T) uint64 {
n, e := file.Read(&buf);
len += n;
if e == EOF {
- break
+ break;
}
if e != nil {
t.Fatal("read failed:", err);
}
}
- return uint64(len)
+ return uint64(len);
}
func TestStat(t *testing.T) {
@@ -120,7 +120,7 @@ func testReaddirnames(dir string, contents []string, t *testing.T) {
if found {
t.Error("present twice:", m);
}
- found = true
+ found = true;
}
}
if !found {
@@ -146,7 +146,7 @@ func testReaddir(dir string, contents []string, t *testing.T) {
if found {
t.Error("present twice:", m);
}
- found = true
+ found = true;
}
}
if !found {
@@ -175,12 +175,12 @@ func smallReaddirnames(file *File, length int, t *testing.T) []string {
t.Fatalf("readdir %q failed: %v", file.Name(), err);
}
if len(d) == 0 {
- break
+ break;
}
names[count] = d[0];
count++;
}
- return names[0:count]
+ return names[0:count];
}
// Check that reading a directory one entry at a time gives the same result
@@ -210,8 +210,8 @@ func TestReaddirnamesOneAtATime(t *testing.T) {
func TestHardLink(t *testing.T) {
from, to := "hardlinktestfrom", "hardlinktestto";
- Remove(from); // Just in case.
- file, err := Open(to, O_CREAT | O_WRONLY, 0666);
+ Remove(from); // Just in case.
+ file, err := Open(to, O_CREAT|O_WRONLY, 0666);
if err != nil {
t.Fatalf("open %q failed: %v", to, err);
}
@@ -239,8 +239,8 @@ func TestHardLink(t *testing.T) {
func TestSymLink(t *testing.T) {
from, to := "symlinktestfrom", "symlinktestto";
- Remove(from); // Just in case.
- file, err := Open(to, O_CREAT | O_WRONLY, 0666);
+ Remove(from); // Just in case.
+ file, err := Open(to, O_CREAT|O_WRONLY, 0666);
if err != nil {
t.Fatalf("open %q failed: %v", to, err);
}
@@ -297,7 +297,7 @@ func TestSymLink(t *testing.T) {
func TestLongSymlink(t *testing.T) {
s := "0123456789abcdef";
- s = s + s + s + s + s + s + s + s + s + s + s + s + s + s + s + s + s;
+ s = s+s+s+s+s+s+s+s+s+s+s+s+s+s+s+s+s;
from := "longsymlinktestfrom";
err := Symlink(s, from);
if err != nil {
@@ -347,7 +347,7 @@ func checkMode(t *testing.T, path string, mode uint32) {
func TestChmod(t *testing.T) {
MkdirAll("_obj", 0777);
const Path = "_obj/_TestChmod_";
- fd, err := Open(Path, O_WRONLY | O_CREAT, 0666);
+ fd, err := Open(Path, O_WRONLY|O_CREAT, 0666);
if err != nil {
t.Fatalf("create %s: %s", Path, err);
}
@@ -386,7 +386,7 @@ func TestChown(t *testing.T) {
// basically useless.
const Path = "/tmp/_TestChown_";
- fd, err := Open(Path, O_WRONLY | O_CREAT, 0666);
+ fd, err := Open(Path, O_WRONLY|O_CREAT, 0666);
if err != nil {
t.Fatalf("create %s: %s", Path, err);
}
@@ -439,7 +439,7 @@ func checkSize(t *testing.T, path string, size uint64) {
func TestTruncate(t *testing.T) {
MkdirAll("_obj", 0777);
const Path = "_obj/_TestTruncate_";
- fd, err := Open(Path, O_WRONLY | O_CREAT, 0666);
+ fd, err := Open(Path, O_WRONLY|O_CREAT, 0666);
if err != nil {
t.Fatalf("create %s: %s", Path, err);
}
@@ -454,7 +454,7 @@ func TestTruncate(t *testing.T) {
fd.Truncate(0);
checkSize(t, Path, 0);
fd.Write(strings.Bytes("surprise!"));
- checkSize(t, Path, 13 + 9); // wrote at offset past where hello, world was.
+ checkSize(t, Path, 13+9); // wrote at offset past where hello, world was.
fd.Close();
Remove(Path);
}
@@ -466,7 +466,7 @@ func TestChdirAndGetwd(t *testing.T) {
}
// These are chosen carefully not to be symlinks on a Mac
// (unlike, say, /var, /etc, and /tmp).
- dirs := []string{ "/bin", "/", "/usr/bin" };
+ dirs := []string{"/bin", "/", "/usr/bin"};
for mode := 0; mode < 2; mode++ {
for _, d := range dirs {
if mode == 0 {
@@ -529,19 +529,19 @@ func TestSeek(t *testing.T) {
io.WriteString(f, data);
type test struct {
- in int64;
- whence int;
- out int64;
- }
- var tests = []test {
- test{ 0, 1, int64(len(data)) },
- test{ 0, 0, 0 },
- test{ 5, 0, 5 },
- test{ 0, 2, int64(len(data)) },
- test{ 0, 0, 0 },
- test{ -1, 2, int64(len(data)) - 1 },
- test{ 1<<40, 0, 1<<40 },
- test{ 1<<40, 2, 1<<40 + int64(len(data)) }
+ in int64;
+ whence int;
+ out int64;
+ }
+ var tests = []test{
+ test{0, 1, int64(len(data))},
+ test{0, 0, 0},
+ test{5, 0, 5},
+ test{0, 2, int64(len(data))},
+ test{0, 0, 0},
+ test{-1, 2, int64(len(data))-1},
+ test{1<<40, 0, 1<<40},
+ test{1<<40, 2, 1<<40 + int64(len(data))},
};
for i, tt := range tests {
off, err := f.Seek(tt.in, tt.whence);
@@ -553,23 +553,23 @@ func TestSeek(t *testing.T) {
}
type openErrorTest struct {
- path string;
- mode int;
- error string;
+ path string;
+ mode int;
+ error string;
}
-var openErrorTests = []openErrorTest {
- openErrorTest {
+var openErrorTests = []openErrorTest{
+ openErrorTest{
"/etc/no-such-file",
O_RDONLY,
"open /etc/no-such-file: no such file or directory",
},
- openErrorTest {
+ openErrorTest{
"/etc",
O_WRONLY,
"open /etc: is a directory",
},
- openErrorTest {
+ openErrorTest{
"/etc/passwd/group",
O_WRONLY,
"open /etc/passwd/group: not a directory",
@@ -607,7 +607,7 @@ func run(t *testing.T, cmd []string) string {
Wait(pid, 0);
output := b.String();
if n := len(output); n > 0 && output[n-1] == '\n' {
- output = output[0:n-1];
+ output = output[0 : n-1];
}
if output == "" {
t.Fatalf("%v produced no output", cmd);
diff --git a/src/pkg/os/path.go b/src/pkg/os/path.go
index ca157e50c..de4b020d4 100644
--- a/src/pkg/os/path.go
+++ b/src/pkg/os/path.go
@@ -35,7 +35,7 @@ func MkdirAll(path string, perm int) Error {
if j > 0 {
// Create parent
- err = MkdirAll(path[0:j-1], perm);
+ err = MkdirAll(path[0 : j-1], perm);
if err != nil {
return err;
}
@@ -91,7 +91,7 @@ func RemoveAll(path string) Error {
for {
names, err1 := fd.Readdirnames(100);
for _, name := range names {
- err1 := RemoveAll(path + "/" + name);
+ err1 := RemoveAll(path+"/"+name);
if err == nil {
err = err1;
}
diff --git a/src/pkg/os/path_test.go b/src/pkg/os/path_test.go
index d7f595711..cfdd64fc0 100644
--- a/src/pkg/os/path_test.go
+++ b/src/pkg/os/path_test.go
@@ -5,8 +5,8 @@
package os_test
import (
- . "os";
- "testing";
+ . "os";
+ "testing";
)
func TestMkdirAll(t *testing.T) {
@@ -26,7 +26,7 @@ func TestMkdirAll(t *testing.T) {
// Make file.
fpath := path + "/file";
- _, err = Open(fpath, O_WRONLY | O_CREAT, 0666);
+ _, err = Open(fpath, O_WRONLY|O_CREAT, 0666);
if err != nil {
t.Fatalf("create %q: %s", fpath, err);
}
@@ -65,13 +65,13 @@ func TestRemoveAll(t *testing.T) {
// Work directory.
path := "_obj/_TestRemoveAll_";
fpath := path + "/file";
- dpath := path + "/dir";
+ dpath := path+"/dir";
// Make directory with 1 file and remove.
if err := MkdirAll(path, 0777); err != nil {
t.Fatalf("MkdirAll %q: %s", path, err);
}
- fd, err := Open(fpath, O_WRONLY | O_CREAT, 0666);
+ fd, err := Open(fpath, O_WRONLY|O_CREAT, 0666);
if err != nil {
t.Fatalf("create %q: %s", fpath, err);
}
@@ -87,12 +87,12 @@ func TestRemoveAll(t *testing.T) {
if err = MkdirAll(dpath, 0777); err != nil {
t.Fatalf("MkdirAll %q: %s", dpath, err);
}
- fd, err = Open(fpath, O_WRONLY | O_CREAT, 0666);
+ fd, err = Open(fpath, O_WRONLY|O_CREAT, 0666);
if err != nil {
t.Fatalf("create %q: %s", fpath, err);
}
fd.Close();
- fd, err = Open(dpath+"/file", O_WRONLY | O_CREAT, 0666);
+ fd, err = Open(dpath + "/file", O_WRONLY|O_CREAT, 0666);
if err != nil {
t.Fatalf("create %q: %s", fpath, err);
}
@@ -109,8 +109,8 @@ func TestRemoveAll(t *testing.T) {
t.Fatalf("MkdirAll %q: %s", dpath, err);
}
- for _, s := range []string{fpath, dpath+"/file1", path+"/zzz"} {
- fd, err = Open(s, O_WRONLY | O_CREAT, 0666);
+ for _, s := range []string{fpath, dpath + "/file1", path+"/zzz"} {
+ fd, err = Open(s, O_WRONLY|O_CREAT, 0666);
if err != nil {
t.Fatalf("create %q: %s", s, err);
}
diff --git a/src/pkg/os/proc.go b/src/pkg/os/proc.go
index 3a6f5a16f..0dd295edf 100644
--- a/src/pkg/os/proc.go
+++ b/src/pkg/os/proc.go
@@ -8,8 +8,8 @@ package os
import "syscall"
-var Args []string; // provided by runtime
-var Envs []string; // provided by runtime
+var Args []string // provided by runtime
+var Envs []string // provided by runtime
// Getuid returns the numeric user id of the caller.
@@ -43,4 +43,3 @@ func Getgroups() ([]int, Error) {
func Exit(code int) {
syscall.Exit(code);
}
-
diff --git a/src/pkg/os/stat_darwin_386.go b/src/pkg/os/stat_darwin_386.go
index cc6e54966..b8b2fe3a2 100644
--- a/src/pkg/os/stat_darwin_386.go
+++ b/src/pkg/os/stat_darwin_386.go
@@ -9,7 +9,7 @@ package os
import "syscall"
func isSymlink(stat *syscall.Stat_t) bool {
- return stat.Mode & syscall.S_IFMT == syscall.S_IFLNK
+ return stat.Mode & syscall.S_IFMT == syscall.S_IFLNK;
}
func dirFromStat(name string, dir *Dir, lstat, stat *syscall.Stat_t) *Dir {
@@ -26,9 +26,9 @@ func dirFromStat(name string, dir *Dir, lstat, stat *syscall.Stat_t) *Dir {
dir.Atime_ns = uint64(syscall.TimespecToNsec(stat.Atimespec));
dir.Mtime_ns = uint64(syscall.TimespecToNsec(stat.Mtimespec));
dir.Ctime_ns = uint64(syscall.TimespecToNsec(stat.Ctimespec));
- for i := len(name) - 1; i >= 0; i-- {
+ for i := len(name)-1; i >= 0; i-- {
if name[i] == '/' {
- name = name[i+1:len(name)];
+ name = name[i+1 : len(name)];
break;
}
}
diff --git a/src/pkg/os/stat_darwin_amd64.go b/src/pkg/os/stat_darwin_amd64.go
index c6f031a24..d7400b210 100644
--- a/src/pkg/os/stat_darwin_amd64.go
+++ b/src/pkg/os/stat_darwin_amd64.go
@@ -9,7 +9,7 @@ package os
import "syscall"
func isSymlink(stat *syscall.Stat_t) bool {
- return stat.Mode & syscall.S_IFMT == syscall.S_IFLNK
+ return stat.Mode & syscall.S_IFMT == syscall.S_IFLNK;
}
func dirFromStat(name string, dir *Dir, lstat, stat *syscall.Stat_t) *Dir {
@@ -26,9 +26,9 @@ func dirFromStat(name string, dir *Dir, lstat, stat *syscall.Stat_t) *Dir {
dir.Atime_ns = uint64(syscall.TimespecToNsec(stat.Atimespec));
dir.Mtime_ns = uint64(syscall.TimespecToNsec(stat.Mtimespec));
dir.Ctime_ns = uint64(syscall.TimespecToNsec(stat.Ctimespec));
- for i := len(name) - 1; i >= 0; i-- {
+ for i := len(name)-1; i >= 0; i-- {
if name[i] == '/' {
- name = name[i+1:len(name)];
+ name = name[i+1 : len(name)];
break;
}
}
diff --git a/src/pkg/os/stat_linux_386.go b/src/pkg/os/stat_linux_386.go
index d08fabcc6..a1df33028 100644
--- a/src/pkg/os/stat_linux_386.go
+++ b/src/pkg/os/stat_linux_386.go
@@ -13,7 +13,7 @@ package os
import "syscall"
func isSymlink(stat *syscall.Stat_t) bool {
- return stat.Mode & syscall.S_IFMT == syscall.S_IFLNK
+ return stat.Mode & syscall.S_IFMT == syscall.S_IFLNK;
}
func dirFromStat(name string, dir *Dir, lstat, stat *syscall.Stat_t) *Dir {
@@ -30,9 +30,9 @@ func dirFromStat(name string, dir *Dir, lstat, stat *syscall.Stat_t) *Dir {
dir.Atime_ns = uint64(syscall.TimespecToNsec(stat.Atim));
dir.Mtime_ns = uint64(syscall.TimespecToNsec(stat.Mtim));
dir.Ctime_ns = uint64(syscall.TimespecToNsec(stat.Ctim));
- for i := len(name) - 1; i >= 0; i-- {
+ for i := len(name)-1; i >= 0; i-- {
if name[i] == '/' {
- name = name[i+1:len(name)];
+ name = name[i+1 : len(name)];
break;
}
}
diff --git a/src/pkg/os/stat_linux_amd64.go b/src/pkg/os/stat_linux_amd64.go
index f4c300b2c..dcc29c04e 100644
--- a/src/pkg/os/stat_linux_amd64.go
+++ b/src/pkg/os/stat_linux_amd64.go
@@ -9,7 +9,7 @@ package os
import "syscall"
func isSymlink(stat *syscall.Stat_t) bool {
- return stat.Mode & syscall.S_IFMT == syscall.S_IFLNK
+ return stat.Mode & syscall.S_IFMT == syscall.S_IFLNK;
}
func dirFromStat(name string, dir *Dir, lstat, stat *syscall.Stat_t) *Dir {
@@ -26,9 +26,9 @@ func dirFromStat(name string, dir *Dir, lstat, stat *syscall.Stat_t) *Dir {
dir.Atime_ns = uint64(syscall.TimespecToNsec(stat.Atim));
dir.Mtime_ns = uint64(syscall.TimespecToNsec(stat.Mtim));
dir.Ctime_ns = uint64(syscall.TimespecToNsec(stat.Ctim));
- for i := len(name) - 1; i >= 0; i-- {
+ for i := len(name)-1; i >= 0; i-- {
if name[i] == '/' {
- name = name[i+1:len(name)];
+ name = name[i+1 : len(name)];
break;
}
}
diff --git a/src/pkg/os/stat_linux_arm.go b/src/pkg/os/stat_linux_arm.go
index d08fabcc6..a1df33028 100644
--- a/src/pkg/os/stat_linux_arm.go
+++ b/src/pkg/os/stat_linux_arm.go
@@ -13,7 +13,7 @@ package os
import "syscall"
func isSymlink(stat *syscall.Stat_t) bool {
- return stat.Mode & syscall.S_IFMT == syscall.S_IFLNK
+ return stat.Mode & syscall.S_IFMT == syscall.S_IFLNK;
}
func dirFromStat(name string, dir *Dir, lstat, stat *syscall.Stat_t) *Dir {
@@ -30,9 +30,9 @@ func dirFromStat(name string, dir *Dir, lstat, stat *syscall.Stat_t) *Dir {
dir.Atime_ns = uint64(syscall.TimespecToNsec(stat.Atim));
dir.Mtime_ns = uint64(syscall.TimespecToNsec(stat.Mtim));
dir.Ctime_ns = uint64(syscall.TimespecToNsec(stat.Ctim));
- for i := len(name) - 1; i >= 0; i-- {
+ for i := len(name)-1; i >= 0; i-- {
if name[i] == '/' {
- name = name[i+1:len(name)];
+ name = name[i+1 : len(name)];
break;
}
}
diff --git a/src/pkg/os/stat_nacl_386.go b/src/pkg/os/stat_nacl_386.go
index 83b0d6c38..67b2ba8c8 100644
--- a/src/pkg/os/stat_nacl_386.go
+++ b/src/pkg/os/stat_nacl_386.go
@@ -13,7 +13,7 @@ package os
import "syscall"
func isSymlink(stat *syscall.Stat_t) bool {
- return stat.Mode & syscall.S_IFMT == syscall.S_IFLNK
+ return stat.Mode & syscall.S_IFMT == syscall.S_IFLNK;
}
func dirFromStat(name string, dir *Dir, lstat, stat *syscall.Stat_t) *Dir {
@@ -27,12 +27,12 @@ func dirFromStat(name string, dir *Dir, lstat, stat *syscall.Stat_t) *Dir {
dir.Size = uint64(stat.Size);
dir.Blksize = uint64(stat.Blksize);
dir.Blocks = uint64(stat.Blocks);
- dir.Atime_ns = uint64(stat.Atime)*1e9;
- dir.Mtime_ns = uint64(stat.Mtime)*1e9;
- dir.Ctime_ns = uint64(stat.Ctime)*1e9;
- for i := len(name) - 1; i >= 0; i-- {
+ dir.Atime_ns = uint64(stat.Atime) * 1e9;
+ dir.Mtime_ns = uint64(stat.Mtime) * 1e9;
+ dir.Ctime_ns = uint64(stat.Ctime) * 1e9;
+ for i := len(name)-1; i >= 0; i-- {
if name[i] == '/' {
- name = name[i+1:len(name)];
+ name = name[i+1 : len(name)];
break;
}
}
diff --git a/src/pkg/os/time.go b/src/pkg/os/time.go
index d0ba6e1fa..f5c2880a1 100644
--- a/src/pkg/os/time.go
+++ b/src/pkg/os/time.go
@@ -16,6 +16,5 @@ func Time() (sec int64, nsec int64, err Error) {
if errno := syscall.Gettimeofday(&tv); errno != 0 {
return 0, 0, NewSyscallError("gettimeofday", errno);
}
- return int64(tv.Sec), int64(tv.Usec)*1000, err;
+ return int64(tv.Sec), int64(tv.Usec) * 1000, err;
}
-
diff --git a/src/pkg/os/types.go b/src/pkg/os/types.go
index b5db86660..7ed547c9b 100644
--- a/src/pkg/os/types.go
+++ b/src/pkg/os/types.go
@@ -10,66 +10,65 @@ 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 {
- Dev uint64; // device number of file system holding file.
- Ino uint64; // inode number.
- Nlink uint64; // number of hard links.
- Mode uint32; // permission and mode bits.
- Uid uint32; // user id of owner.
- Gid uint32; // group id of owner.
- Rdev uint64; // device type for special file.
- Size uint64; // length in bytes.
- Blksize uint64; // size of blocks, in bytes.
- Blocks uint64; // number of blocks allocated for file.
+ Dev uint64; // device number of file system holding file.
+ Ino uint64; // inode number.
+ Nlink uint64; // number of hard links.
+ Mode uint32; // permission and mode bits.
+ Uid uint32; // user id of owner.
+ Gid uint32; // group id of owner.
+ Rdev uint64; // device type for special file.
+ Size uint64; // length in bytes.
+ Blksize uint64; // size of blocks, in bytes.
+ Blocks uint64; // number of blocks allocated for file.
Atime_ns uint64; // access time; nanoseconds since epoch.
Mtime_ns uint64; // modified time; nanoseconds since epoch.
Ctime_ns uint64; // status change time; nanoseconds since epoch.
- Name string; // name of file as presented to Open.
- FollowedSymlink bool; // followed a symlink to get this information
+ Name string; // name of file as presented to Open.
+ FollowedSymlink bool; // followed a symlink to get this information
}
// IsFifo reports whether the Dir describes a FIFO file.
func (dir *Dir) IsFifo() bool {
- return (dir.Mode & syscall.S_IFMT) == syscall.S_IFIFO
+ 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
+ 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
+ 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
+ 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
+ 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
+ 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
+ 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)
+ return int(dir.Mode & 0777);
}
-