How to Watch Golang Files: Gowatch vs Gow
Why do I Care?
The obvious: I’m lazy and I don’t want to recompile myself. I want my computer to do all the hard work, watch my files, and reload them automatically for me, restarting any services.
A Tale of Two Packages
So I trolled the internet and found two packages: gowatch and gow. Now: which should I use, why, and how?
First, a Summary
They’re fairly equivalent and you can get by with either one. It’s really just a personal preference. Both have been actively updated withing a few weeks of publishing this article, October 27, 2022.
#1 gowatch
pros:
https://github.com/silenceper/gowatch
#2 gow
pros:
- Hotkeys
https://github.com/mitranim/gow
Installs
You’ll need to make your go binaries available to your shell, if you haven’t already.
# use your go bin path and shell profile
echo "export PATH="${PATH}:/go/bin" >> ~/.zshrc
source ~/.zshrc
gowatch
go install github.com/silenceper/gowatch@latest
Run
gowatch
gow
go install github.com/mitranim/gow@latest
Run
gow run .
