All Projects → mitranim → gow

mitranim / gow

Licence: Unlicense license
Missing watch mode for Go commands. Watch Go files and execute a command like "go run" or "go test"

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to gow

nss-run
nss-run (not so simple run) is a very simplistic build tool.
Stars: ✭ 14 (-95.92%)
Mutual labels:  task-runner, build-tool
Task
A task runner / simpler Make alternative written in Go
Stars: ✭ 4,282 (+1148.4%)
Mutual labels:  task-runner, build-tool
alfred
(v0.2) Even Batman needs a little help. Task runner. Automator. Build system.
Stars: ✭ 62 (-81.92%)
Mutual labels:  task-runner, build-tool
makesure
Simple task/command runner with declarative goals and dependencies
Stars: ✭ 230 (-32.94%)
Mutual labels:  task-runner, build-tool
Doit
task management & automation tool
Stars: ✭ 972 (+183.38%)
Mutual labels:  task-runner, build-tool
rote
Automate everything.
Stars: ✭ 66 (-80.76%)
Mutual labels:  task-runner, build-tool
Air
☁️ Live reload for Go apps
Stars: ✭ 5,257 (+1432.65%)
Mutual labels:  task-runner, build-tool
alfons
🚀 Task runner for Lua and MoonScript.
Stars: ✭ 17 (-95.04%)
Mutual labels:  task-runner, build-tool
Cargo Make
Rust task runner and build tool.
Stars: ✭ 895 (+160.93%)
Mutual labels:  task-runner, build-tool
Mask
🎭 A CLI task runner defined by a simple markdown file
Stars: ✭ 495 (+44.31%)
Mutual labels:  task-runner, build-tool
Realize
Realize is the #1 Golang Task Runner which enhance your workflow by automating the most common tasks and using the best performing Golang live reloading.
Stars: ✭ 4,162 (+1113.41%)
Mutual labels:  task-runner, build-tool
Mmake
Mmake is a small program which wraps make to provide additional functionality, such as user-friendly help output, remote includes, and eventually more. It otherwise acts as a pass-through to standard make.
Stars: ✭ 1,593 (+364.43%)
Mutual labels:  task-runner, build-tool
Ygor
Task toolkit. For when `npm run` isn't enough and everything else is too much.
Stars: ✭ 69 (-79.88%)
Mutual labels:  task-runner, build-tool
Foy
A simple, light-weight and modern task runner for general purpose.
Stars: ✭ 157 (-54.23%)
Mutual labels:  task-runner, build-tool
GN-demo
Demonstrate building a C++ program with GN
Stars: ✭ 33 (-90.38%)
Mutual labels:  build-tool
llmk
Light LaTeX Make
Stars: ✭ 93 (-72.89%)
Mutual labels:  build-tool
goreleaser-xx
Cross compilation helper for GoReleaser
Stars: ✭ 34 (-90.09%)
Mutual labels:  build-tool
next-boilerplate
☶ The easiest way to create a Next app by running one command.
Stars: ✭ 65 (-81.05%)
Mutual labels:  build-tool
redparty
Host Youtube watch party with friends. Sync videos and chat in real-time
Stars: ✭ 70 (-79.59%)
Mutual labels:  watch
AnimeDLR
AnimeDLR
Stars: ✭ 47 (-86.3%)
Mutual labels:  watch

Overview

Go Watch: missing watch mode for the go command. It's invoked exactly like go, but also watches Go files and reruns on changes.

Currently requires Unix (MacOS, Linux, BSD). On Windows, runs under WSL.

TOC

Why

Why not other runners, general-purpose watchers, etc:

  • Has hotkeys, such as ctrl+r to restart!
  • Go-specific, easy to remember.
  • Ignores non-Go files by default.
  • Better watcher: recursive, no delays, no polling; uses https://github.com/rjeczalik/notify.
  • Silent by default.
  • No garbage files.
  • Can properly clear the terminal on restart.
  • Does not leak subprocesses.
  • Minimal dependencies.

Installation

Make sure you have Go installed, then run this:

go install github.com/mitranim/gow@latest

This should download the source and compile the executable into $GOPATH/bin/gow. Make sure $GOPATH/bin is in your $PATH so the shell can discover the gow command. For example, my ~/.profile contains this:

export GOPATH="$HOME/go"
export PATH="$GOPATH/bin:$PATH"

Alternatively, you can run the executable using the full path. At the time of writing, ~/go is the default $GOPATH for Go installations. Some systems may have a different one.

~/go/bin/gow

On MacOS, if installation fails with dylib-related errors, you may need to run xcode-select --install or install Xcode. This is caused by gow's dependencies, which depend on C. See #15.

Usage

The first argument to gow, after the flags, can be any Go subcommand: build, install, tool, you name it.

# Start and restart on change
gow run .

# Pass args to the program
gow run . arg0 arg1 ...

# Run subdirectory
gow run ./subdir

# Vet and re-vet on change; verbose mode is recommended
gow -v vet

# Clear terminal on restart
gow -c run .

# Specify file extension to watch
gow -e=go,mod,html run .

# Help
gow -h

Hotkeys

Supported control codes with commonly associated hotkeys. Exact keys may vary between terminal apps. For example, ^- in MacOS Terminal vs ^? in iTerm2.

3     ^C          Kill subprocess with SIGINT.
18    ^R          Kill subprocess with SIGTERM, restart.
20    ^T          Kill subprocess with SIGTERM.
28    ^\          Kill subprocess with SIGQUIT.
31    ^- or ^?    Print currently running command.

Other input is forwarded to the subprocess as-is.

Watching Templates

Many Go programs, such as servers, include template files, and want to recompile those templates on change.

Easy but slow way: use gow -e.

gow -e=go,mod,html run .

This restarts your entire app on change to any .html file in the current directory or sub-directories. Beware: if the app also generates files with the same extensions, this could cause an infinite restart loop. Ignore any output directories with -i:

gow -e=go,mod,html -i=target run .

A smarter approach would be to watch the template files from inside the app and recompile them without restarting the entire app. This is out of scope for gow.

Finally, you can use a pure-Go rendering system such as github.com/mitranim/gax.

Alternatives

For general purpose file watching, consider these excellent tools:

License

https://unlicense.org

Misc

I'm receptive to suggestions. If this tool almost satisfies you but needs changes, open an issue or chat me up. Contacts: https://mitranim.com/#contacts

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].