23 Star 82 Fork 13

silenceper / gowatch

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

gowatch

Go Go Report Card

Go 程序热编译工具,提升开发效率

通过监听当前目录下的相关文件变动,进行实时编译

安装使用

使用 go insall 命令安装 gowatch

go install github.com/silenceper/gowatch@latest

安装完成之后,即可使用gowatch命令,在当前文件执行:

gowatch

命令行参数

  • -o : 非必须,指定build的目标文件路径
  • -p : 非必须,指定需要build的package(也可以是单个文件)
  • -args: 非必须,指定程序运行时参数,例如:-args='-host=:8080,-name=demo'
  • -v: 非必须,显示gowatch版本信息
  • -h: 非必须,帮助信息

例子:

gowatch -o ./bin/demo -p ./cmd/demo

配置文件

gowatch.yml

大部分情况下,不需要更改配置,直接执行gowatch命令就能满足的大部分的需要,但是也提供了一些配置用于自定义

可以通过以下命令生成默认配置

gowatch init

会在执行目录下创建gowatch.yml文件

# gowatch.yml 配置示例

# 当前目录执行下生成的可执行文件的名字,默认是当前目录名
appname: "test"

# 指定编译完成后执行的命令,可指定自定义脚本
run_cmd: "./run.sh"

# 指定编译后的目标文件目录
output: /bin/demo

# 需要追加监听的文件名后缀,默认只有'.go'文件
watch_exts:
    - .yml

# 需要监听的目录,默认只有当前目录
watch_paths:
    - ../pk

# 在执行命令时,需要增加的其他参数
cmd_args:
    - arg1=val1

# 在构建命令时,需要增加的其他参数
build_args:
    - -race

# 需要增加环境变量,默认已加载当前环境变量
envs:
    - a=b

# 是否监听 ‘vendor’ 文件夹下的文件改变
vendor_watch: false

# 不需要监听的目录名字
excluded_paths:
    - path

# main 包路径,也可以是单个文件,多个文件使用逗号分隔
build_pkg: ""

# build tags
build_tags: ""

#在build app执行的命令 ,例如 swag init	
#prev_build_cmds:	
#  - swag init

# 是否禁止自动运行
disable_run: false

微信公众号

关注公众号入群交流

关注公众号并回复“入群”

Inspired by bee

MIT License Copyright (c) 2016 silenceper Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

golang 程序热编译工具,提升开发效率 展开 收起
Go
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Go
1
https://gitee.com/silenceper/gowatch.git
git@gitee.com:silenceper/gowatch.git
silenceper
gowatch
gowatch
master

搜索帮助