summaryrefslogtreecommitdiff
path: root/src/inotify/inutil
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2015-09-12 11:20:19 -0600
committerLuke Shumaker <lukeshu@sbcglobal.net>2015-09-12 11:20:19 -0600
commit8e49597e479f878b5e9aff6d738717eaa11c5cb7 (patch)
tree85eaef78b0218c6c29498dc5866c2f27dfa5f944 /src/inotify/inutil
parente8199ec88c7ca8107c4fb9238e383a4a9eb981ee (diff)
gofmt, use make(chan) without a number argument where possible
Diffstat (limited to 'src/inotify/inutil')
-rw-r--r--src/inotify/inutil/inotify_util.go84
1 files changed, 42 insertions, 42 deletions
diff --git a/src/inotify/inutil/inotify_util.go b/src/inotify/inutil/inotify_util.go
index 46146f5..3a5eed5 100644
--- a/src/inotify/inutil/inotify_util.go
+++ b/src/inotify/inutil/inotify_util.go
@@ -1,78 +1,78 @@
package inutil
import (
- "inotify"
- "os"
- "syscall"
+ "inotify"
+ "os"
+ "syscall"
)
const (
// Flags for the parameter of InotifyInit1().
// These, oddly, appear to be 24-bit numbers.
- IN_CLOEXEC = inotify.IN_CLOEXEC
+ IN_CLOEXEC = inotify.IN_CLOEXEC
)
type Watcher struct {
- Events <-chan inotify.Event
- events chan<- inotify.Event
- Errors <-chan error
- errors chan<- error
- in *inotify.Inotify
+ Events <-chan inotify.Event
+ events chan<- inotify.Event
+ Errors <-chan error
+ errors chan<- error
+ in *inotify.Inotify
}
func WatcherInit() (*Watcher, error) {
- in, err := inotify.InotifyInit()
- return newWatcher(in, err)
+ in, err := inotify.InotifyInit()
+ return newWatcher(in, err)
}
func WatcherInit1(flags int) (*Watcher, error) {
- in, err := inotify.InotifyInit1(flags&^inotify.IN_NONBLOCK)
- return newWatcher(in, err)
+ in, err := inotify.InotifyInit1(flags &^ inotify.IN_NONBLOCK)
+ return newWatcher(in, err)
}
func newWatcher(in *inotify.Inotify, err error) (*Watcher, error) {
- events := make(chan inotify.Event, 1)
- errors := make(chan error, 1)
- o := &Watcher{
- Events: events,
- events: events,
- Errors: errors,
- errors: errors,
- in: in,
- }
- go o.worker()
- return o, err
+ events := make(chan inotify.Event)
+ errors := make(chan error)
+ o := &Watcher{
+ Events: events,
+ events: events,
+ Errors: errors,
+ errors: errors,
+ in: in,
+ }
+ go o.worker()
+ return o, err
}
func (o *Watcher) AddWatch(path string, mask inotify.Mask) (inotify.Wd, error) {
- return o.in.AddWatch(path, mask);
+ return o.in.AddWatch(path, mask)
}
func (o *Watcher) RmWatch(wd inotify.Wd) error {
- return o.in.RmWatch(wd);
+ return o.in.RmWatch(wd)
}
func (o *Watcher) Close() {
- func() {
- defer recover()
- close(o.events)
- close(o.errors)
- }()
- go o.in.Close()
+ func() {
+ defer recover()
+ close(o.events)
+ close(o.errors)
+ }()
+ go o.in.Close()
}
func (o *Watcher) worker() {
- defer recover()
- for {
- ev, err := o.in.Read();
+ defer recover()
+ for {
+ ev, err := o.in.Read()
if ev.Wd >= 0 {
- o.events <- ev
- }
- if err != nil {
- if err.(*os.SyscallError).Err == syscall.EBADF {
- o.Close()
- }
- o.errors <- err
+ o.events <- ev
+ }
+ if err != nil {
+ if err.(*os.SyscallError).Err == syscall.EBADF {
+ o.Close()
+ }
+ o.errors <- err
}
}
}