go-watcher golang 写的热重载轮子 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
The Go Programming Language
http://golang.org/
Go Playground
Go Projects
Revel Web Framework
yeqown
V2EX    Go 编程语言

go-watcher golang 写的热重载轮子

  •  
  •   yeqown
    yeqown 2019-03-31 21:42:39 +08:00 2776 次点击
    这是一个创建于 2394 天前的主题,其中的信息可能已经有所发展或是发生改变。

    go-watcher

    Go Report Card GoReportCard

    Golang 编写的热重载工具,自定义命令,支持监视文件及路径配置,环境变量配置。这是一个重复的轮子~

    安装使用

    go install github.com/yeqown/go-watcher/cmd/go-watcher 

    命令行

     go-watcher git:(master) ./go-watcher -h NAME: go-watcher - A new cli application USAGE: go-watcher [global options] command [command options] [arguments...] VERSION: 2.0.0 AUTHOR: [email protected] COMMANDS: init generate a config file to specified postion 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 command GLOBAL 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 - .git envs: # 额外的环境变量 - 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 watching rm -fr package go build -o package/osx/go-watcher cmd/go-watcher/main.go GOOS=linux GOARCH=amd64 go build -o package/linux/go-watcher cmd/go-watcher/main.go mkdir -p package/archived tar -zcvf package/archived/go-watcher.osx.tar.gz package/osx a package/osx a package/osx/go-watcher tar -zcvf package/archived/go-watcher.linux.tar.gz package/linux a package/linux a 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] changed rm -fr package mkdir -p package/osx mkdir -p package/linux echo "2.0.0" > VERSION cp VERSION package/osx cp VERSION package/linux go build -o package/osx/go-watcher cmd/go-watcher/main.go GOOS=linux GOARCH=amd64 go build -o package/linux/go-watcher cmd/go-watcher/main.go mkdir -p package/archived tar -zcvf package/archived/go-watcher.osx.tar.gz package/osx a package/osx a package/osx/go-watcher a package/osx/VERSION tar -zcvf package/archived/go-watcher.linux.tar.gz package/linux a package/linux a 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 filetype a 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) 
    目前尚无回复
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     2236 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 23ms UTC 16:00 PVG 00:00 LAX 09:00 JFK 12:00
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86