This repository has been archived on 2020-11-18. You can view files and clone it, but cannot push or open issues or pull requests.
n3rdpad-agent/agent.go

44 lines
748 B
Go

package main
import (
"fmt"
"log"
"github.com/fsnotify/fsnotify"
)
func watchForConfigChanges() {
watcher, err := fsnotify.NewWatcher()
if err != nil {
log.Fatal(err)
}
defer watcher.Close()
done := make(chan bool)
go func() {
for {
select {
case event := <-watcher.Events:
log.Println("event: ", event)
if event.Op&fsnotify.Write == fsnotify.Write {
log.Println("modified file:", event.Name)
}
case err := <-watcher.Errors:
log.Println("error:", err)
}
}
}()
// TODO: Add working directory
err = watcher.Add("/tmp/test")
if err != nil {
log.Fatal(err)
}
<-done
}
func main() {
fmt.Printf("Ready\n")
watchForConfigChanges()
}