Skip to content

A simple fsnotify wrapper to watch file updates correctly

License

Notifications You must be signed in to change notification settings

SagerNet/fswatch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fswatch

Test Lint Go Reference

fswatch is a simple fsnotify wrapper to watch file updates correctly.

Install

go get github.com/sagernet/fswatch

Example

package main

import (
	"log"

	"github.com/sagernet/fswatch"
)

func main() {
	var watchPath []string
	watchPath = append(watchPath, "/tmp/my_file")
	watcher, err := fswatch.NewWatcher(fswatch.Options{
		Path: watchPath,
		Callback: func(path string) {
			log.Println("file updated: ", path)
		},
	})
	if err != nil {
		log.Fatal(err)
	}
	defer watcher.Close()
	// Block main goroutine forever.
	<-make(chan struct{})
}

About

A simple fsnotify wrapper to watch file updates correctly

Resources

License

Stars

Watchers

Forks

Packages

No packages published