https://github.com/marwan-at-work/gowatch
A simple .go file watcher that will stop & restart main.go
https://github.com/marwan-at-work/gowatch
filewatcher fsnotify go golang nodemon
Last synced: about 1 year ago
JSON representation
A simple .go file watcher that will stop & restart main.go
- Host: GitHub
- URL: https://github.com/marwan-at-work/gowatch
- Owner: marwan-at-work
- License: bsd-3-clause
- Created: 2017-03-24T22:29:53.000Z (over 9 years ago)
- Default Branch: main
- Last Pushed: 2024-11-23T19:22:43.000Z (over 1 year ago)
- Last Synced: 2025-03-22T12:24:29.885Z (over 1 year ago)
- Topics: filewatcher, fsnotify, go, golang, nodemon
- Language: Go
- Size: 652 KB
- Stars: 16
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

A simple Go file watcher that will stop & restart your `main()` function on file changes.
## Motivation
I just want to stop my server, and run it again every time I save a file.
## installation
`go install marwan.io/gowatch@latest`
## Usage
from your main app directory, run `gowatch`
## What it does
it reads your current working directory and runs the two typical commands:
- `go build`
- `./`
So this only works in `main` packages.
Also, this ignores your `vendor` folder & your `_test.go` files.
#### FAQ
Q: Why doesn't it just run `go run main.go`?
A: `go run` does the same thing as `go build`, but calls the resulting binary as a subprocess. This makes it harder to reach `stdout` and killing the `main.go` process, won't necessarily kill the subprocess, so you end up trying to run the server twice (which ends up with "port is already taken" kind of error).
Q: How does it compare with other tools?
A: I haven't tried most of them, but I wanted to make this as simple as just running one command to get what I'm looking for without having to turn and twist a lot of knobs.