Skip to content

livebud/watcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Watcher

Go Reference

Resilient file watcher. Used in Bud.

Features

  • Watches a directory recursively
  • Debounces multiple events into a single function call
  • Smooths over differences between operating systems
  • Ignores files in your .gitignore
  • Generally does what you'd expect

Install

go get -u github.com/livebud/watcher

Example

package main

import (
  "context"
  "fmt"
  "os"

  "github.com/livebud/watcher"
)

func main() {
  ctx := context.Background()
  if err := run(ctx); err != nil {
    fmt.Fprintln(os.Stderr, err)
    os.Exit(1)
  }
}

func run(ctx context.Context) error {
  return watcher.Watch(ctx, ".", func(events []watcher.Event) error {
    for _, event := range events {
      fmt.Println(string(event.Op), event.Path)
    }
    return nil
  })
}

Contributing

Thank you for your interest in contributing! To get started, first clone the repo:

git clone https://github.com/livebud/watcher
cd watcher

Next, install the dependencies:

go mod tidy

Finally, try running the tests:

go test ./...

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published