`go test` file modification monitoring for automated testing

automated-tests, go, unit-testing

Solution

You can use `inotifywait` for that. Example watching some dir and executing `go test` on close while having data written:

inotifywait -e close_write <dir> | while read file; do go test; done

Or you write your own tool in go utilizing the `howeyc/fsnotify` package: Similar example application.

There's also rerun, written in ruby:

rerun go test

Above command will watch the current directory for changes and run `go test` when a change occurs.

Problem

Is there a way to have `go test` run whenever a project's files are modified? Perhaps there is a good general solution to run a command when files in a path are modified that could be used for this use?

Original source