| 12345678910111213141516171819202122232425 |
- package main
- import (
- "fmt"
- "github.com/fsnotify/fsnotify"
- )
- func main(){
- watcher, _ := fsnotify.NewWatcher()
- watcher.Add("test.txt")
- defer watcher.Close();
- select {
- case event := <-watcher.Events:
- {
- if event.Op&fsnotify.Rename == fsnotify.Rename || event.Op&fsnotify.Remove == fsnotify.Remove {
- fmt.Println("delete")
- } else if event.Op&fsnotify.Write == fsnotify.Write {
- } else if event.Op&fsnotify.Create == fsnotify.Create {
- }
- }
- case err := <-watcher.Errors:
- fmt.Println(err.Error())
- }
- }
|