From 7bfb53d70817f392276e146476bab0eb5332f54b Mon Sep 17 00:00:00 2001 From: Nathan Youngman Date: Sat, 21 Jun 2014 21:16:33 -0600 Subject: [PATCH] Events channel of type Event rather than *Event. --- fsnotify_bsd.go | 9 ++++----- fsnotify_linux.go | 8 ++++---- fsnotify_windows.go | 8 ++++---- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/fsnotify_bsd.go b/fsnotify_bsd.go index 25823cc..cdc38e1 100644 --- a/fsnotify_bsd.go +++ b/fsnotify_bsd.go @@ -33,9 +33,8 @@ const ( keventWaitTime = 100e6 ) -func newEvent(name string, mask uint32, create bool) *Event { - e := new(Event) - e.Name = name +func newEvent(name string, mask uint32, create bool) Event { + e := Event{Name: name} if create { e.Op |= Create } @@ -69,7 +68,7 @@ type Watcher struct { externalWatches map[string]bool // Map of watches added by user of the library. ewmut sync.Mutex // Protects access to externalWatches. Errors chan error // Errors are sent on this channel - Events chan *Event // Events are returned on this channel + Events chan Event // Events are returned on this channel done chan bool // Channel for sending a "quit message" to the reader goroutine isClosed bool // Set to true when Close() is first called } @@ -88,7 +87,7 @@ func NewWatcher() (*Watcher, error) { finfo: make(map[int]os.FileInfo), fileExists: make(map[string]bool), externalWatches: make(map[string]bool), - Events: make(chan *Event), + Events: make(chan Event), Errors: make(chan error), done: make(chan bool, 1), } diff --git a/fsnotify_linux.go b/fsnotify_linux.go index 72b1ee1..591b055 100644 --- a/fsnotify_linux.go +++ b/fsnotify_linux.go @@ -20,8 +20,8 @@ const ( syscall.IN_MOVE_SELF | syscall.IN_DELETE | syscall.IN_DELETE_SELF ) -func newEvent(name string, mask uint32) *Event { - e := &Event{Name: name} +func newEvent(name string, mask uint32) Event { + e := Event{Name: name} if mask&syscall.IN_CREATE == syscall.IN_CREATE || mask&syscall.IN_MOVED_TO == syscall.IN_MOVED_TO { e.Op |= Create } @@ -51,7 +51,7 @@ type Watcher struct { watches map[string]*watch // Map of inotify watches (key: path) paths map[int]string // Map of watched paths (key: watch descriptor) Errors chan error // Errors are sent on this channel - Events chan *Event // Events are returned on this channel + Events chan Event // Events are returned on this channel done chan bool // Channel for sending a "quit message" to the reader goroutine isClosed bool // Set to true when Close() is first called } @@ -66,7 +66,7 @@ func NewWatcher() (*Watcher, error) { fd: fd, watches: make(map[string]*watch), paths: make(map[int]string), - Events: make(chan *Event), + Events: make(chan Event), Errors: make(chan error), done: make(chan bool, 1), } diff --git a/fsnotify_windows.go b/fsnotify_windows.go index 9699217..d0c7e25 100644 --- a/fsnotify_windows.go +++ b/fsnotify_windows.go @@ -39,8 +39,8 @@ const ( sys_FS_Q_OVERFLOW = 0x4000 ) -func newEvent(name string, mask uint32) *Event { - e := &Event{Name: name} +func newEvent(name string, mask uint32) Event { + e := Event{Name: name} if mask&sys_FS_CREATE == sys_FS_CREATE { e.Op |= Create } @@ -101,7 +101,7 @@ type Watcher struct { port syscall.Handle // Handle to completion port watches watchMap // Map of watches (key: i-number) input chan *input // Inputs to the reader are sent on this channel - Events chan *Event // Events are returned on this channel + Events chan Event // Events are returned on this channel Errors chan error // Errors are sent on this channel isClosed bool // Set to true when Close() is first called quit chan chan<- error @@ -117,7 +117,7 @@ func NewWatcher() (*Watcher, error) { port: port, watches: make(watchMap), input: make(chan *input, 1), - Events: make(chan *Event, 50), + Events: make(chan Event, 50), Errors: make(chan error), quit: make(chan chan<- error, 1), } -- 2.50.1