Golang编写的热重载工具,自定义命令,支持监视文件及路径配置,环境变量配置。这是一个重复的轮子~地址在:github.com/yeqown/go-watcher,欢迎fork和PR。安装使用go install github.com/yeqown/go-watcher/cmd/go-watcher命令行➜ go-watcher git:(master) ✗ ./go-watcher -h NAME: go-watcher - A new cli applicationUSAGE: go-watcher [global options] command [command options] [arguments…]VERSION: 2.0.0AUTHOR: yeqown@gmail.comCOMMANDS: init generate a config file to specified position run execute a command, and watch the files, if any change to these files, the command will reload help, h Shows a list of commands or help for one commandGLOBAL OPTIONS: –help, -h show help –version, -v print the version配置文件watcher: # 监视器配置 duration: 2000 # 文件修改时间间隔,只有高于这个间隔才回触发重载 included_filetypes: # 监视的文件扩展类型 - .go # excluded_regexps: # 不被监视更改的文件正则表达式 - ^.gitignore$ - ‘.yml$’ - ‘.txt$‘additional_paths: [] # 除了当前文件夹需要额外监视的文件夹excluded_paths: # 不需要监视的文件名,若为相对路径,只能对于当前路径生效- vendor- .gitenvs: # 额外的环境变量- GOROOT=/path/to/your/goroot- GOPATH=/path/to/your/gopath使用范例日志➜ go-watcher git:(master) ✗ ./package/osx/go-watcher run -e “make” -c ./config.yml[INFO] directory (/Users/yeqown/Projects/opensource/go-watcher) is under watching[INFO] directory (/Users/yeqown/Projects/opensource/go-watcher/cmd) is under watching[INFO] directory (/Users/yeqown/Projects/opensource/go-watcher/cmd/go-watcher) is under watching[INFO] directory (/Users/yeqown/Projects/opensource/go-watcher/internal) is under watching[INFO] directory (/Users/yeqown/Projects/opensource/go-watcher/internal/command) is under watching[INFO] directory (/Users/yeqown/Projects/opensource/go-watcher/internal/log) is under watching[INFO] directory (/Users/yeqown/Projects/opensource/go-watcher/internal/testdata) is under watching[INFO] directory (/Users/yeqown/Projects/opensource/go-watcher/internal/testdata/exclude) is under watching[INFO] directory (/Users/yeqown/Projects/opensource/go-watcher/internal/testdata/testdata_inner) is under watching[INFO] directory (/Users/yeqown/Projects/opensource/go-watcher/package) is under watching[INFO] directory (/Users/yeqown/Projects/opensource/go-watcher/package/archived) is under watching[INFO] directory (/Users/yeqown/Projects/opensource/go-watcher/package/linux) is under watching[INFO] directory (/Users/yeqown/Projects/opensource/go-watcher/package/osx) is under watching[INFO] directory (/Users/yeqown/Projects/opensource/go-watcher/resources) is under watching[INFO] directory (/Users/yeqown/Projects/opensource/go-watcher/utils) is under watching[INFO] directory (/Users/yeqown/Projects/opensource/go-watcher/utils/testdata) is under watching[INFO] directory (/Users/yeqown/Projects/opensource/go-watcher/utils/testdata/testdata_inner) is under watchingrm -fr packagego build -o package/osx/go-watcher cmd/go-watcher/main.goGOOS=linux GOARCH=amd64 go build -o package/linux/go-watcher cmd/go-watcher/main.gomkdir -p package/archivedtar -zcvf package/archived/go-watcher.osx.tar.gz package/osxa package/osxa package/osx/go-watchertar -zcvf package/archived/go-watcher.linux.tar.gz package/linuxa package/linuxa package/linux/go-watcher[INFO] command executed done![INFO] (/Users/yeqown/Projects/opensource/go-watcher/package/osx/go-watcher) is skipped, not target filetype[INFO] (/Users/yeqown/Projects/opensource/go-watcher/package/osx) is skipped, not target filetype[INFO] (/Users/yeqown/Projects/opensource/go-watcher/package) is skipped, not target filetype[INFO] (/Users/yeqown/Projects/opensource/go-watcher/package/linux/go-watcher) is skipped, not target filetype[INFO] (/Users/yeqown/Projects/opensource/go-watcher/package/linux) is skipped, not target filetype[INFO] (/Users/yeqown/Projects/opensource/go-watcher/package/archived/go-watcher.linux.tar.gz) is skipped, not target filetype[INFO] (/Users/yeqown/Projects/opensource/go-watcher/package/archived) is skipped, not target filetype[INFO] (/Users/yeqown/Projects/opensource/go-watcher/VERSION) is skipped, not target filetype[INFO] [/Users/yeqown/Projects/opensource/go-watcher/cmd/go-watcher/main.go] changedrm -fr packagemkdir -p package/osxmkdir -p package/linuxecho “2.0.0” > VERSIONcp VERSION package/osxcp VERSION package/linuxgo build -o package/osx/go-watcher cmd/go-watcher/main.goGOOS=linux GOARCH=amd64 go build -o package/linux/go-watcher cmd/go-watcher/main.gomkdir -p package/archivedtar -zcvf package/archived/go-watcher.osx.tar.gz package/osxa package/osxa package/osx/go-watchera package/osx/VERSIONtar -zcvf package/archived/go-watcher.linux.tar.gz package/linuxa package/linuxa package/linux/go-watcher[INFO] (/Users/yeqown/Projects/opensource/go-watcher/package/osx) is skipped, not target filetype[INFO] (/Users/yeqown/Projects/opensource/go-watcher/package/linux) is skipped, not target filetypea package/linux/VERSION[INFO] command executed done![INFO] (/Users/yeqown/Projects/opensource/go-watcher/package/osx) is skipped, not target filetype[INFO] (/Users/yeqown/Projects/opensource/go-watcher/package/archived) is skipped, not target filetype[INFO] (/Users/yeqown/Projects/opensource/go-watcher/package) is skipped, not target filetype[INFO] (/Users/yeqown/Projects/opensource/go-watcher/VERSION) is skipped, not target filetype[INFO] (/Users/yeqown/Projects/opensource/go-watcher/package) is skipped, not target filetype^C[INFO] quit signal captured![INFO] go-watcher exited➜ go-watcher git:(master) ✗