Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTibor Vass <tvass@stumbleupon.com>2014-01-30 02:50:31 +0400
committerspf13 <steve.francia@gmail.com>2014-01-30 03:03:35 +0400
commit6dd2e9a49acde23dcf5e9701915f7e8ed692ce5a (patch)
treedbbc04239e25626868fad3e7faab656c26e3715a /watcher
parentff9f6e1b2a000a24e677b9a3fa8dfbdef11c404c (diff)
gofmt all go code
Diffstat (limited to 'watcher')
-rw-r--r--watcher/batcher.go112
1 files changed, 56 insertions, 56 deletions
diff --git a/watcher/batcher.go b/watcher/batcher.go
index a22ad8b41..7e9ce8861 100644
--- a/watcher/batcher.go
+++ b/watcher/batcher.go
@@ -1,56 +1,56 @@
-package watcher
-
-import (
- "github.com/howeyc/fsnotify"
- "time"
-)
-
-type Batcher struct {
- *fsnotify.Watcher
- interval time.Duration
- done chan struct{}
-
- Event chan []*fsnotify.FileEvent // Events are returned on this channel
-}
-
-func New(interval time.Duration) (*Batcher, error) {
- watcher, err := fsnotify.NewWatcher()
-
- batcher := &Batcher{}
- batcher.Watcher = watcher
- batcher.interval = interval
- batcher.done = make(chan struct{}, 1)
- batcher.Event = make(chan []*fsnotify.FileEvent, 1)
-
- if err == nil {
- go batcher.run()
- }
-
- return batcher, err
-}
-
-func (b *Batcher) run() {
- tick := time.Tick(b.interval)
- evs := make([]*fsnotify.FileEvent, 0)
-OuterLoop:
- for {
- select {
- case ev := <-b.Watcher.Event:
- evs = append(evs, ev)
- case <-tick:
- if len(evs) == 0 {
- continue
- }
- b.Event <- evs
- evs = make([]*fsnotify.FileEvent, 0)
- case <-b.done:
- break OuterLoop
- }
- }
- close(b.done)
-}
-
-func (b *Batcher) Close() {
- b.done <- struct{}{}
- b.Watcher.Close()
-}
+package watcher
+
+import (
+ "github.com/howeyc/fsnotify"
+ "time"
+)
+
+type Batcher struct {
+ *fsnotify.Watcher
+ interval time.Duration
+ done chan struct{}
+
+ Event chan []*fsnotify.FileEvent // Events are returned on this channel
+}
+
+func New(interval time.Duration) (*Batcher, error) {
+ watcher, err := fsnotify.NewWatcher()
+
+ batcher := &Batcher{}
+ batcher.Watcher = watcher
+ batcher.interval = interval
+ batcher.done = make(chan struct{}, 1)
+ batcher.Event = make(chan []*fsnotify.FileEvent, 1)
+
+ if err == nil {
+ go batcher.run()
+ }
+
+ return batcher, err
+}
+
+func (b *Batcher) run() {
+ tick := time.Tick(b.interval)
+ evs := make([]*fsnotify.FileEvent, 0)
+OuterLoop:
+ for {
+ select {
+ case ev := <-b.Watcher.Event:
+ evs = append(evs, ev)
+ case <-tick:
+ if len(evs) == 0 {
+ continue
+ }
+ b.Event <- evs
+ evs = make([]*fsnotify.FileEvent, 0)
+ case <-b.done:
+ break OuterLoop
+ }
+ }
+ close(b.done)
+}
+
+func (b *Batcher) Close() {
+ b.done <- struct{}{}
+ b.Watcher.Close()
+}