※ Click here for the Japanese version
fresher
is a hot reload tool that restarts the Go application when the group of monitored files changes.
This tool is a library that implements the minimum required functions at https://github.com/gravityblast/fresh and add some functions to monitor more efficiently and efficiently.
Developing for better-fresh
.
fresher
supports the following features.
- Features of https://github.com/gravityblast/fresh
- Flexible setting of monitoring file
- Execute Command before and after build
- Support to set env and args for build
- Build with local and run with docker, hot reload faster with docker
go get github.com/kanataxa/fresher/cmd/fresher
go get github.com/kanataxa/fresher/cmd/fresher
touch your_config.yml
path:
- .
fresher -c your_config.yml
See here for a simple example in _example
.
you can determine the files to be monitored in more detail by making two settings
- Set
path
finely - Set
exclude
Basically, the file to be monitored is determined from the configuration file according to the following rules.
-
Starting from the directory described in path, recursively determine whether it is a file to be monitored
-
If include is specified, only directories that are recursively viewed and files to be monitored should match those specified in include. If they match files set in exclude, Exclude from monitoring
-
include / exclude does not distinguish between files and directories, and uses filepath.Match to monitor / exclude matches
If you want to ignore everything, exclude it with exclude
.
If you want to monitor / ignore specific files and directories in that directory, specify include / exclude
in path
.
The following is an example.
bash-3.2$ tree ./
./
├── fresher_config.yml
├── main.go
├── controller
│ ├── controller.go
│ └── const.go
├── model
│ ├── message.go
│ └── message_test.go
└── pkg
├── config.go
├── const.go
├── pkg.go
└── utils
├── utils.go
└── utils_test.go
path:
- .
- name: controller
exclude:
- const.go
- model
- name: pkg
include:
- utils*
- config.go
exclude:
- vendor
- '*_test.go'
Include the following settings in the build
field, launch a docker
container and execute fresher
on the host side.
GOOS
and GOARCH
need to be set when the host and container OS are different.
fresher
cross-compiles and runs the binary in docker
.
build:
host:
docker: container_name
env:
GOOS: linux
GOARCH: amd64
If you want to cross-compile binaries containing cgo
, you need to prepare.
-
Prepare
c / c ++
compiler for cross compilation -
If the c source used for cgo uses an external library, compile with the compiler prepared in step 1 and prepare it as a static library
-
Make the following settings in the configuration file
build:
host:
docker: container
env:
GOOS: linux
GOARCH: amd64
CC: /your/cross-compile-cc-compiler/path
CXX: /your/cross-compile-cxx-compiler/path
CGO_ENABLED: 1
CGO_LDFLAGS: /your/static/lib/libz.a
CGO_CXXFLAGS: -I/your/header/path/include
arg:
- --ldflags
- '-linkmode external -extldflags -static'
Please create Issue
in English or Japanese.
MIT