minor cleanup

master
vilmibm 2020-06-12 22:03:46 +00:00
parent df979ff7a1
commit 349936a9b4
4 changed files with 66 additions and 0 deletions

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
bustle
*.swp
# ---> Go
# Binaries for programs and plugins
*.exe

7
go.mod 100644
View File

@ -0,0 +1,7 @@
module git.tilde.town/tildetown/bustle
go 1.14
require (
github.com/fsnotify/fsnotify v1.4.9
)

4
go.sum 100644
View File

@ -0,0 +1,4 @@
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9 h1:L2auWcuQIvxz9xSEqzESnV/QN/gNRXNApHi3fYwl2w0=
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=

53
main.go 100644
View File

@ -0,0 +1,53 @@
package main
import (
"fmt"
"log"
"os"
"github.com/fsnotify/fsnotify"
)
func main() {
watcher, err := fsnotify.NewWatcher()
if err != nil {
log.Fatal(err)
}
defer watcher.Close()
done := make(chan bool)
go func() {
for {
select {
case event, ok := <-watcher.Events:
if !ok {
return
}
log.Println("event:", event)
if event.Op&fsnotify.Write == fsnotify.Write {
log.Println("modified file:", event.Name)
}
case err, ok := <-watcher.Errors:
if !ok {
return
}
log.Println("error:", err)
}
}
}()
// will need to recursively watch for myself, including adding watchers for new directories D:
// check out filepath.Walk
for _, path := range os.Args[1:] {
err = watcher.Add(path)
if err != nil {
log.Fatal(err)
}
}
<-done
fmt.Println("hmm")
}