2015-01-22 15:00:51 +01:00
2014-11-04 19:22:43 +01:00
2015-02-08 15:55:43 +01:00
2014-09-26 16:22:25 +02:00
2015-01-21 22:41:21 +01:00
2014-10-11 20:09:34 +02:00
2014-09-08 18:09:34 +02:00
2015-01-21 22:41:21 +01:00
2015-01-29 17:42:07 +01:00
2015-01-17 14:37:22 +01:00
2015-01-21 22:41:21 +01:00
2015-01-21 22:41:21 +01:00
2015-01-27 08:48:30 +01:00
2015-01-24 19:11:07 +01:00

notify Build Status Build Status Build Status Build status Coverage Status

Filesystem event notification library on steroids. (under active development)

Installation

~ $ go get -u github.com/rjeczalik/notify

Documentation

godoc.org/github.com/rjeczalik/notify

Usage

Watching recursively all events on a single chan.

package main

import (
	"log"

	"github.com/rjeczalik/notify"
)

func main() {
	c := make(chan notify.EventInfo, 16)

	if err := notify.Watch("./...", c, notify.All); err != nil {
		log.Fatal(err)
	}
	defer notify.Stop(c)

	for ei := range c {
		log.Println(ei.Event(), ei.Path())
	}
}

Event error handling.

package main

import (
	"log"

	"github.com/rjeczalik/notify"
)

func main() {
	c := make(chan notify.EventInfo, 1)

	if err := notify.Watch(".", c, notify.Create); err != nil {
		log.Fatal(err)
	}
	defer notify.Stop(c)

	for ei := range c {
		switch ei.Event() {
		case notify.Error:
			log.Fatal(ei.Sys().(error))
		default:
			log.Println(ei)
		}
	}
}

Watching multiple events on a single chan.

package main

import (
	"log"

	"github.com/rjeczalik/notify"
)

func main() {
	c := make(chan notify.EventInfo, 1)

	if err := notify.Watch(".", c, notify.Create, notify.Write); err != nil {
		log.Fatal(err)
	}
	defer notify.Stop(c)

	for ei := range c {
		switch ei.Event() {
		case notify.Create:
			log.Println("create", ei)
		case notify.Write:
			log.Println("write", ei)
		}
	}
}

Watching multiple events on multiple chans.

package main

import (
	"log"

	"github.com/rjeczalik/notify"
)

func main() {
	create := make(chan notify.EventInfo, 1)
	write := make(chan notify.EventInfo, 1)

	if err := notify.Watch(".", create, notify.Create); err != nil {
		log.Fatal(err)
	}
	defer notify.Stop(create)

	if err := notify.Watch(".", write, notify.Write); err != nil {
		log.Fatal(err)
	}
	defer notify.Stop(write)

	for {
		select {
		case ei := <-create:
			log.Println("create", ei)
		case ei := <-write:
			log.Println("write", ei)
		}
	}
}
S
Description
File system event notification library on steroids.
Readme MIT
981 KiB
Languages
Go 100%