diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2015-09-12 11:20:19 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2015-09-12 11:20:19 -0600 |
commit | 8e49597e479f878b5e9aff6d738717eaa11c5cb7 (patch) | |
tree | 85eaef78b0218c6c29498dc5866c2f27dfa5f944 /src/inotify/inotify.go | |
parent | e8199ec88c7ca8107c4fb9238e383a4a9eb981ee (diff) |
gofmt, use make(chan) without a number argument where possible
Diffstat (limited to 'src/inotify/inotify.go')
-rw-r--r-- | src/inotify/inotify.go | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/inotify/inotify.go b/src/inotify/inotify.go index 9cbae17..0d67b44 100644 --- a/src/inotify/inotify.go +++ b/src/inotify/inotify.go @@ -1,16 +1,15 @@ package inotify import ( + "sync" "syscall" "unsafe" - "sync" ) type Inotify struct { fd Fd fdLock sync.RWMutex - - fullbuff [4096]byte + buffFull [4096]byte buff []byte buffLock sync.Mutex } @@ -27,7 +26,7 @@ func InotifyInit() (*Inotify, error) { o := Inotify{ fd: fd, } - o.buff = o.fullbuff[:0] + o.buff = o.buffFull[:0] return &o, err } @@ -36,7 +35,7 @@ func InotifyInit1(flags int) (*Inotify, error) { o := Inotify{ fd: fd, } - o.buff = o.fullbuff[:0] + o.buff = o.buffFull[:0] return &o, err } @@ -55,7 +54,7 @@ func (o *Inotify) RmWatch(wd Wd) error { func (o *Inotify) Close() error { o.fdLock.Lock() defer o.fdLock.Unlock() - defer func() { o.fd = -1; }() + defer func() { o.fd = -1 }() return sysclose(o.fd) } @@ -65,14 +64,14 @@ func (o *Inotify) Read() (Event, error) { if len(o.buff) == 0 { o.fdLock.RLock() - len, err := sysread(o.fd, o.fullbuff[:]) + len, err := sysread(o.fd, o.buffFull[:]) o.fdLock.RUnlock() if len == 0 { return Event{Wd: -1}, o.Close() } else if len < 0 { return Event{Wd: -1}, err } - o.buff = o.fullbuff[0:len] + o.buff = o.buffFull[0:len] } raw := (*syscall.InotifyEvent)(unsafe.Pointer(&o.buff[0])) |