Skip to content

Commit

Permalink
golint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gmccue committed May 24, 2018
1 parent 1d8f9ae commit e8fe4a0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion samefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ package watcher

import "os"

func SameFile(fi1, fi2 os.FileInfo) bool {
func sameFile(fi1, fi2 os.FileInfo) bool {
return os.SameFile(fi1, fi2)
}
2 changes: 1 addition & 1 deletion samefile_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package watcher

import "os"

func SameFile(fi1, fi2 os.FileInfo) bool {
func sameFile(fi1, fi2 os.FileInfo) bool {
return fi1.ModTime() == fi2.ModTime() &&
fi1.Size() == fi2.Size() &&
fi1.Mode() == fi2.Mode() &&
Expand Down
9 changes: 6 additions & 3 deletions watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func (e Event) String() string {
return "???"
}

// Watcher describes a process that watches files for changes.
type Watcher struct {
Event chan Event
Error chan error
Expand Down Expand Up @@ -211,7 +212,7 @@ func (w *Watcher) list(name string) (map[string]os.FileInfo, error) {
return fileList, nil
}

// Add adds either a single file or directory recursively to the file list.
// AddRecursive adds either a single file or directory recursively to the file list.
func (w *Watcher) AddRecursive(name string) (err error) {
w.mu.Lock()
defer w.mu.Unlock()
Expand Down Expand Up @@ -292,7 +293,7 @@ func (w *Watcher) Remove(name string) (err error) {
return nil
}

// Remove removes either a single file or a directory recursively from
// RemoveRecursive removes either a single file or a directory recursively from
// the file's list.
func (w *Watcher) RemoveRecursive(name string) (err error) {
w.mu.Lock()
Expand Down Expand Up @@ -346,6 +347,7 @@ func (w *Watcher) Ignore(paths ...string) (err error) {
return nil
}

// WatchedFiles retruns a map of files added to a Watcher.
func (w *Watcher) WatchedFiles() map[string]os.FileInfo {
w.mu.Lock()
defer w.mu.Unlock()
Expand Down Expand Up @@ -560,7 +562,7 @@ func (w *Watcher) pollEvents(files map[string]os.FileInfo, evt chan Event,
// Check for renames and moves.
for path1, info1 := range removes {
for path2, info2 := range creates {
if SameFile(info1, info2) {
if sameFile(info1, info2) {
e := Event{
Op: Move,
Path: fmt.Sprintf("%s -> %s", path1, path2),
Expand Down Expand Up @@ -606,6 +608,7 @@ func (w *Watcher) Wait() {
w.wg.Wait()
}

// Close stops a Watcher and unlocks its mutex, then sends a close signal.
func (w *Watcher) Close() {
w.mu.Lock()
if !w.running {
Expand Down

0 comments on commit e8fe4a0

Please sign in to comment.