Golang package to watch a glob pattern for changes.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
script
.travis.yml
README.mkd
main.go
main_test.go

README.mkd

globwatch

Golang package to watch a glob pattern for changes.

Example:

package main

import (
    "fmt"
    "github.com/tomnomnom/globwatch"
)

func main() {
    // Watch returns a channel of events and a control channel to stop the watching
    // func Watch(pattern string, sleepInMs int) (<-chan Event, chan<- bool)
    evs, _ := globwatch.Watch("*.log", 100)

    for ev := range evs {
        switch ev.Type() {
        case globwatch.Added:
        fmt.Printf("Added: %s\n", ev.Filename())
        case globwatch.Deleted:
        fmt.Printf("Deleted: %s\n", ev.Filename())
        case globwatch.Truncated:
        fmt.Printf("Truncated: %s\n", ev.Filename())
        }
    }
}

Build Status