使用codegangsta/gin包做热更新

此处gin有别于web gin框架 一个是codegangsta/gin 一个是gin-gonic/gin

安装

go get github.com/codegangsta/gin  

测试

gin -h  

如果出现 command not found : gin ,将$GOPATH/bin/gin移到$GOROOT/bin目录下

cp $GOPATH/bin/gin $GOROOT/bin

基础用法

gin run main.go  

可选参数

   --laddr value, -l value       listening address for the proxy server
   --port value, -p value        port for the proxy server (default: 3000)
   --appPort value, -a value     port for the Go web server (default: 3001)
   --bin value, -b value         name of generated binary file (default: "gin-bin")
   --path value, -t value        Path to watch files from (default: ".")
   --build value, -d value       Path to build files from (defaults to same value as --path)
   --excludeDir value, -x value  Relative directories to exclude
   --immediate, -i               run the server immediately after it's built
   --all                         reloads whenever any file changes, as opposed to reloading only on .go file change
   --godep, -g                   use godep when building
   --buildArgs value             Additional go build arguments
   --certFile value              TLS Certificate
   --keyFile value               TLS Certificate Key
   --logPrefix value             Setup custom log prefix
   --notifications               enable desktop notifications
   --help, -h                    show help
   --version, -v                 print the version

ex:开发端口:8080 -- gin端口 3000

gin -p 3000 -a 8080 run main.go  
修改文件 
自动build
访问 localhost:3000 即可