Go to file
Max Claus Nunes 1fde6281f1 Ignore go-tmp-unmask
Closes https://github.com/maxcnunes/gaper/issues/13
2022-08-07 10:47:30 -03:00
cmd/gaper Update cli to v2 2022-08-07 10:40:15 -03:00
testdata Add extensions example 2022-08-07 10:30:58 -03:00
.editorconfig Initial commit 2018-06-17 19:53:26 -03:00
.gitignore Improve test coverage 2018-07-12 10:27:07 -03:00
.goreleaser.yml Move cli to a different folder so Godoc works for the rest 2018-06-22 13:45:45 -03:00
.travis.yml Move cli to a different folder so Godoc works for the rest 2018-06-22 13:45:45 -03:00
CONTRIBUTING.md Add extensions example 2022-08-07 10:30:58 -03:00
LICENSE Initial commit 2018-06-17 19:53:26 -03:00
Makefile Remove dep script 2019-11-21 19:04:37 -03:00
README.md Improve examples doc 2021-12-18 08:01:38 -03:00
appveyor.yml Fix appveyor setting 2018-06-22 22:14:56 -03:00
builder.go Show build details when a build fails 2018-09-08 10:35:29 -03:00
builder_test.go Support multiple extensions with comma 2022-08-07 10:10:24 -03:00
gaper.go Support multiple extensions with comma 2022-08-07 10:10:24 -03:00
gaper_test.go Don't leave during a restart failure 2018-08-06 10:48:19 -03:00
go.mod Update cli to v2 2022-08-07 10:40:15 -03:00
go.sum Update cli to v2 2022-08-07 10:40:15 -03:00
gopher-gaper.png Add logo 2018-06-21 22:22:05 -03:00
logger.go Use a single logger instance 2018-10-21 10:17:58 -03:00
logger_test.go Use a single logger instance 2018-10-21 10:17:58 -03:00
runner.go Fix issue of gaper not restarting after a previous failure 2018-11-18 13:37:19 -02:00
runner_test.go Improve test coverage 2018-07-12 10:27:07 -03:00
watcher.go Ignore go-tmp-unmask 2022-08-07 10:47:30 -03:00
watcher_test.go Migrate to go module 2019-11-12 18:37:44 -03:00

README.md

gaper

Used to build and restart a Go project when it crashes or some watched file changes
Aimed to be used in development only.


Software License Linux - Build Status Windows - Build status Coverage Status Go Doc Go Report Card Powered By: GoReleaser

Changelog

See Releases for detailed history changes.

Installation

Using go tooling:

go get -u github.com/maxcnunes/gaper/cmd/gaper

Or, downloading the binary instead (example for version 1.0.3, make sure you are using the latest version though):

curl -SL https://github.com/maxcnunes/gaper/releases/download/v1.0.3/gaper_1.0.3_linux_amd64.tar.gz | tar -xvzf - -C "${GOPATH}/bin"

Usage

NAME:
   gaper - Used to build and restart a Go project when it crashes or some watched file changes

USAGE:
   gaper [global options] command [command options] [arguments...]

VERSION:
   version

COMMANDS:
     help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --bin-name value                 name for the binary built by gaper for the executed program (default current directory name)
   --build-path value               path to the program source code (default: ".")
   --build-args value               arguments used on building the program
   --program-args value             arguments used on executing the program
   --verbose                        turns on the verbose messages from gaper
   --disable-default-ignore         turns off default ignore for hidden files and folders, "*_test.go" files, and vendor folder
   --watch value, -w value          list of folders or files to watch for changes
   --ignore value, -i value         list of folders or files to ignore for changes
   --poll-interval value, -p value  how often in milliseconds to poll watched files for changes (default: 500)
   --extensions value, -e value     extensions to watch for changes (default: "go")
   --no-restart-on value, -n value  don't automatically restart the supervised program if it ends:
                                      if "error", an exit code of 0 will still restart.
                                      if "exit", no restart regardless of exit code.
                                      if "success", no restart only if exit code is 0.
   --help, -h                       show help
   --version, -v                    print the version

Watch and Ignore paths

For those options Gaper supports static paths (e.g. build/, seed.go) or glob paths (e.g. migrations/**/up.go, *_test.go).

On using a path to a directory please add a / at the end (e.g. build/) to make sure Gaper won't include other matches that starts with that same value (e.g. build/, build_settings.go).

Default ignore settings

Since in most projects there is no need to watch changes of:

  • hidden files and folders
  • test files (*_test.go)
  • vendor folder

Gaper by default ignores those cases already. Although, if you need Gaper to watch those files anyway it is possible to disable this setting with --disable-default-ignore argument.

Watch method

Currently Gaper uses polling to watch file changes. We have plans to support fs events though in a near future.

Examples

Using all defaults provided by Gaper:

gaper

Example providing a few custom configurations:

gaper \
	--bin-name build/api-dev \
	--build-path cmd/server \
	--build-args "-ldflags=\"-X 'main.Version=dev'" \
	-w 'public/**' -w '*.go' \
	-e js -e css -e html \
	--watch .

Example to ignore watching over all test files:

no need for this if you have not disabled the default ignore settings --disable-default-ignore

--ignore './**/*_test.go'

Contributing

See the Contributing guide for steps on how to contribute to this project.

Reference

This package was heavily inspired by gin and node-supervisor.

Basically, Gaper is a mixing of those projects above. It started from gin code base and I rewrote it aiming to get something similar to node-supervisor (but simpler). A big thanks for those projects and for the people behind it! 👏👏

How is Gaper different of Gin

The main difference is that Gaper removes a layer of complexity from Gin which has a proxy running on top of the executed server. It allows to postpone a build and reload the server when the first call hits it. With Gaper we don't care about that feature, it just restarts your server whenever a change is made.