Skip to content

Commit

Permalink
fix make fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
yinheli committed Jun 28, 2018
1 parent b8a80f4 commit 04e59c5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ deps:
.PHONY: fmt
fmt:
# gofmt code
@gofmt -s -l -w) $(SRC_DIR)
@gofmt -s -l -w $(SRC_DIR)
@go tool vet $(SRC_DIR)

.PHONY: $(CMD)
Expand Down
32 changes: 16 additions & 16 deletions cmd/dev-watcher/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@ package main
import (
"flag"
"fmt"
"runtime"
"github.com/fsnotify/fsnotify"
pkg "github.com/xinpianchang/dev-watcher/watcher"
"log"
"os"
"github.com/fsnotify/fsnotify"
"os/exec"
"path/filepath"
"runtime"
"strings"
"time"
pkg "github.com/xinpianchang/dev-watcher/watcher"
"os/exec"
"sync"
"time"
)

var (
Build = "devel"

dir = flag.String("d", ".", "folder to watch.")
dir = flag.String("d", ".", "folder to watch.")
filters = flag.String("f", "*", "filter file extension, multiple extensions separated by commas.")
wait = flag.Int64("t", 2000, "postpone shell execution until after wait milliseconds.")
script = flag.String("s", "./.dev-watcher.sh", "shell script file which executed after file changed.")
wait = flag.Int64("t", 2000, "postpone shell execution until after wait milliseconds.")
script = flag.String("s", "./.dev-watcher.sh", "shell script file which executed after file changed.")

V = flag.Bool("version", false, "show version")
H = flag.Bool("help", false, "show help")

cmd *exec.Cmd
cmd *exec.Cmd
cmdLock sync.Mutex

l = log.New(os.Stdout, "[dev-watcher] ", log.LstdFlags)
Expand Down Expand Up @@ -57,20 +57,20 @@ func main() {
}
defer watcher.Close()

debounceShellExecutor := pkg.NewDebounce(time.Millisecond * time.Duration(*wait), shellExecutor)
debounceShellExecutor := pkg.NewDebounce(time.Millisecond*time.Duration(*wait), shellExecutor)

go func() {
fileFilter := newFilter(*filters)

for {
select {
case event := <- watcher.Events:
if event.Op & fsnotify.Create == fsnotify.Create ||
event.Op & fsnotify.Remove == fsnotify.Remove ||
event.Op & fsnotify.Rename == fsnotify.Rename ||
event.Op & fsnotify.Write == fsnotify.Write {
case event := <-watcher.Events:
if event.Op&fsnotify.Create == fsnotify.Create ||
event.Op&fsnotify.Remove == fsnotify.Remove ||
event.Op&fsnotify.Rename == fsnotify.Rename ||
event.Op&fsnotify.Write == fsnotify.Write {

if info, err := os.Stat(event.Name); err == nil {
if info, err := os.Stat(event.Name); err == nil {
if info.IsDir() {
continue
}
Expand Down
2 changes: 1 addition & 1 deletion watcher/debounce.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
)

// NewDebounce returns a debounced function
func NewDebounce(d time.Duration, fn func()) (func()) {
func NewDebounce(d time.Duration, fn func()) func() {
last := time.Now().Add(-d)
return func() {
now := time.Now()
Expand Down
4 changes: 2 additions & 2 deletions watcher/debounce_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package watcher

import (
"testing"
"sync/atomic"
"testing"
"time"
)

Expand All @@ -15,7 +15,7 @@ func TestNewDebounce(t *testing.T) {
atomic.AddInt32(&count, 1)
}

fn := NewDebounce(100 * time.Millisecond, f1)
fn := NewDebounce(100*time.Millisecond, f1)

for i := 0; i < 10; i++ {
fn()
Expand Down

0 comments on commit 04e59c5

Please sign in to comment.