gowatch

command module
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 18, 2024 License: BSD-3-Clause Imports: 9 Imported by: 0

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

  • ./<name-of-compiled-binary>

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.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL