Skip to content

Instantly share code, notes, and snippets.

@klingtnet
Created April 15, 2020 12:51
Show Gist options
  • Save klingtnet/03f11a4c9a04a48985af51c3ec5badc9 to your computer and use it in GitHub Desktop.
Save klingtnet/03f11a4c9a04a48985af51c3ec5badc9 to your computer and use it in GitHub Desktop.
Restart a Go web service on file change
#!/bin/sh
set -euo pipefail
command -v reflex &>/dev/null || { cat <<HEREDOC
Please install reflex:
go get -u github.com/cespare/reflex
HEREDOC
exit 1
}
reflex --start-service -- go run ./cmd/server
@klingtnet
Copy link
Author

klingtnet commented Apr 15, 2020

Test and run:

# ...
reflex --start-service -- sh -c 'go test ./... && go run ./cmd/server'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment