- Notifications
You must be signed in to change notification settings - Fork6
Supports live reloading for Go
License
NotificationsYou must be signed in to change notification settings
goccy/rebirth
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Supports live reloading for Go
- Better features than github.com/pilu/fresh
- Supports cross compile and live reloading on host OS for
docker
users (Very Fast forDocker for Mac
user ) - Supports cross compile by cgo ( C/C++ ) ( currently, works on macOS ( and target architecture is
amd64
) only ) - Supports helper commands for
go run
go test
go build
rebirth
needs configuration file (rebirth.yml
) to running .rebirth init
create it .
rebirth.yml
example is the following.
task:migrate:desc:migrate schemacommands: -mysql ....host:docker:container_namebuild:main:path/to/main.go# change path to main package ( default: . )init: -echo 'init hook'# called once at startingbefore: -echo 'before hook'# called before buildafter: -echo 'after hook'# called after buildenv:CGO_LDFLAGS:/usr/local/lib/libz.arun:env:RUNTIME_ENV:"fuga"watch:root: .# root directory for watching ( default: . )ignore: -vendor
task
: define custom commandhost
: specify host information for running to an application ( currently, supportsdocker
only )build
: specify ENV variables for buildingrun
: specify ENV variables for runningwatch
: specifyroot
directory orignore
directories for watching go file
$ GO111MODULE=on go get -u github.com/goccy/rebirth/cmd/rebirth
$ rebirth init
rebirth
Example tree
.├── docker-compose.yml├── main.go└── rebirth.yml
main.go
is your web application's source.
$ GO111MODULE=on go get -u github.com/goccy/rebirth/cmd/rebirth
$ brew install FiloSottile/musl-cross/musl-cross
version:'2'services:app:image:golang:1.13.5container_name:rebirth_appvolumes: -'.:/go/src/app'working_dir:/go/src/appenvironment:GO111MODULE:"on"command:| tail -f /dev/null
host:docker:rebirth_app# container_name in docker-compose.yml
$ rebirth# start live reloading !!# build for docker container's architecture on macOS (e.g. GOOS=linux GOARCH=amd64# execute built binary on target container
Usage: rebirth [OPTIONS]<command>Help Options: -h, --help Show thishelp messageAvailable commands: build execute'go build'command init create rebirth.ymlfor configuration run execute'go run'commandtest execute'go test'command
Help cross compile your go script
$ rebirth build -o app script/hoge.go
Help cross compile forgo test
$ rebirthtest -v ./ -run Hoge
Help cross compile forgo run
$ rebirth run script/hoge.go
~/work/app
directory is mounted on the container as/go/src/app
- install
rebirth
CLI (GO111MODULE=on go get -u github.com/goccy/rebirth/cmd/rebirth
) - run
rebirth
and it cross compile myself for Linux ( GOOS=linux, GOARCH=amd64 ) and put it to.rebirth
directory as__rebirth
- copy
.rebirth/__rebirth
to the container (.rebirth
directory is mounted on the container ) - watch
main.go
( byfsnotify )
- cross compile
main.go
for Linux and put to.rebirth
directory asprogram
- copy
.rebirth/program
to the container
- run
__rebirth
on the container __rebirth
executesprogram
- edit
main.go
rebirth
detects file changed event
- cross compile
main.go
for Linux and put to.rebirth
directory asprogram
- copy
.rebirth/program
to the container rebirth
send signal to__rebirth
for reloading (SIGHUP
)__rebirth
kill the current application and executeprogram
as a new application
MIT
About
Supports live reloading for Go
Topics
Resources
License
Stars
Watchers
Forks
Packages0
No packages published