Galus is a live reloading tool for Go applications, similar to Air or CompileDaemon. It monitors file changes in your project, automatically recompiles, and restarts the application.
-
Live Reloading: Automatically detects changes in specified file types (e.g.,
.go) and recompiles and restarts the application. -
Configurable via .galus.toml: Customize watched directories, file extensions, build commands, and runtime arguments using a TOML configuration file.
-
Colorful CLI Output: Provides clear, color-coded output for better user experience (e.g., green for success, red for errors).
-
Rich CLI Commands: Supports init to create a default configuration file, version to display the app version, and help for command usage details.
-
Graceful Shutdown: Uses
SIGTERMto safely stop running processes, with a fallback to force termination if needed. The grace period is configurable viakill_grace. -
Resilient Reloads: A failed build never kills the currently running binary — the last working version keeps serving until a build succeeds.
-
Debounced File Events: Bursts of file changes (e.g. saving many files at once) are combined into a single rebuild via a configurable debounce window, instead of rebuilding once per event.
-
Full File Event Coverage: Responds to file
create,write,remove, andrenameevents, not just writes. -
Hooks (
pre_cmd/post_cmd): Run commands before building (e.g.go vet,go generate) and after the app restarts. A failingpre_cmdaborts the rebuild and keeps the current process running. -
Environment Variables: Inject env vars into both the build command and the running process via the
envconfig option. -
Polling Fallback: When
polling = true, Galus periodically scans the project for changes instead of relying solely on filesystem events — useful for editors or Docker bind-mounts that don't emitfsnotifyevents reliably. -
Configuration Validation: Ensures build_cmd and command_args are valid before starting the live reload process.
-
Cross-Platform: Works on any platform supported by Go, with easy installation via go get.
-
Install galus using
go get:go get github.com/aliftech/galus
-
Install the binary to make galus available globally:
go install github.com/aliftech/galus
-
Ensure
$GOPATH/binis in your$PATH:export PATH=$PATH:$(go env GOPATH)/bin
-
Initialize a configuration file: In your project directory, run:
galus init
This creates a
.galus.tomlconfiguration file with default setting. -
Start live reloading: In your project directory, run:
galus
Galus will monitor file changes (e.g.,
.gofiles), recompile, and restart your application.
The .galus.toml file allows you to customize Galus behavior. Example configuration:
root_dir = "."
tmp_dir = "tmp"
include_ext = ["go"]
exclude_dir = [".git", "vendor", "tmp"]
build_cmd = "go build -o ./tmp/main ."
binary_name = "tmp/main"
command_args = ["tmp/main"]
kill_grace = "5s"
debounce = "300ms"
pre_cmd = []
post_cmd = []
env = {}
polling = false
polling_interval = "500ms"root_dir: Directory to monitor for changes.tmp_dir: Temporary directory for compiled binaries.include_ext: File extensions to monitor (e.g.,["go", "html"]).exclude_dir: Directories to ignore.build_cmd: Command to compile the application.binary_name: Name of the compiled binary.command_args: Arguments to run the binary.kill_grace: How long to wait for the running process to stop gracefully (viaSIGTERM) before force-killing it.debounce: How long to wait after the last file change before rebuilding, combining bursts of events into a single rebuild.pre_cmd: Commands to run before each build (e.g.["go vet ./...", "go generate ./..."]). If any fails, the rebuild is aborted and the current process keeps running.post_cmd: Commands to run after the app restarts (e.g.["go run ./cmd/gen"]). Failures are logged but do not stop the app.env: Environment variables applied to both the build and the running process (e.g.{ PORT = "8080", DEBUG = "true" }).polling: Set totrueto scan the project periodically instead of relying solely on filesystem events.polling_interval: How often to scan for changes whenpollingis enabled.
