mangar / gowatcher

Watcher in Go Lang. Trigger fired when a file is created/modified/removed from a specific directory.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GoWatcher

Watch changes (remove, create and changes) on a mapped directory and fire a command for each.

Usage

go run gowatcher config.json

Configuration

Create a json file with the content bellow.

  • dir: directory that will be wathed
  • created / change / delete: entry for each action
  • created / change / delete . cmd: command that will be fired for each event (create, change or remove)
{
  "dir":"/Users/marciog/Projects/__temp/golang_changes_file_dir/watch",
  "create":{
    "cmd": "touch `pwd`/log/`date '+%Y%m%d-%H%M%S'`_create.txt"
  },
  "change":{
    "cmd": "touch `pwd`/log/`date '+%Y%m%d-%H%M%S'`_change.txt"
  },
  "delete":{
    "cmd":"touch `pwd`/log/`date '+%Y%m%d-%H%M%S'`_delete.txt"
  }
}

About

Watcher in Go Lang. Trigger fired when a file is created/modified/removed from a specific directory.

License:MIT License


Languages

Language:Go 100.0%