Skip to content
/ notify Public
forked from rjeczalik/notify

File system event notification library on steroids.

License

Notifications You must be signed in to change notification settings

kaocs/notify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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())
	}
}

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)
		}
	}
}

About

File system event notification library on steroids.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%