When I get started with developing websites in Go and gin framework, it's a pity that gin lacks live-reloading function. In fact, I tried fresh and it seems not much flexible, so I intended to rewrite it in a better way. Finally, Air's born. In addition, great thanks to pilu, no fresh, no air :)
Air is yet another live-reloading command line utility for Go applications in development. Just
air in your project root directory, leave it alone,
and focus on your code.
NOTE: This tool has nothing to do with hot-deploy for production.
- colorful log output
- customize go build command
- customize binary execution command
- support excluding subdirectories
- allow watching new directories after Air started
- better building process
curl -fLo ~/.air \ https://raw.githubusercontent.com/cosmtrek/air/master/bin/darwin/air chmod +x ~/.air
curl -fLo ~/.air \ https://raw.githubusercontent.com/cosmtrek/air/master/bin/linux/air chmod +x ~/.air
curl -fLo ~/.air.exe \ https://raw.githubusercontent.com/cosmtrek/air/master/bin/windows/air.exe
P.S. Great thanks mattn's PR for supporting Windows platform.
Please pull this docker image cosmtrek/air.
docker run -it --rm \ -e "air_wd=<YOUR PROJECT DIR>" \ -v $(pwd):<YOUR PROJECT DIR> \ -p <PORT>:<YOUR APP SERVER PORT> \ cosmtrek/air
For example, one of my project runs in docker:
docker run -it --rm \ -e "air_wd=/go/src/github.com/cosmtrek/hub" \ -v $(pwd):/go/src/github.com/cosmtrek/hub \ -p 9090:9090 \ cosmtrek/air
For less typing, you could add
alias air='~/.air' to your
First enter into your project
The simplest usage is run
# firstly find `.air.conf` in current directory, if not found, use defaults air
While I prefer the second way
# 1. create a new file touch .air.conf # 2. paste `air.conf.example` into this file, and **modify it** to satisfy your needs # 3. run air with your configs. If file name is `.air.conf`, just run `air` air -c .air.conf
See the complete air.conf.example
air -d prints all logs.
# 1. fork this project # 2. clone it mkdir -p $GOPATH/src/github.com/cosmtrek cd $GOPATH/src/github.com/cosmtrek git clone firstname.lastname@example.org:<YOUR USERNAME>/air.git # 3. install dependencies cd air make ci # 4. explore it and happy hacking! make install
PRs are welcome~