Go about a hot item compiler tool -gowatch

scenes to be used

Golang project in the preparation process, the need for ongoing project to build go buildand debug in order to quickly identify the problem, and every time we were manually go buildwas too repeated, so to write such a tool gowatchchange to monitor real-time file and compile.

Getting Started

Installation

go get github.com/silenceper/gowatch

After the installation is complete, execute in the main package directory gowatchcommand:gowatch

Advanced Usage

Support command line parameters:

  • -o: not necessarily, specify the build target file path
  • -p: not necessarily, the package needs to specify the build (may also be a single file)
  • -args: not necessarily, the specified program run time parameters, for example: -args = '- host =: 8080, -name = demo'
  • -v: not necessarily, the version information displayed gowatch

E.g:

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

gowatch also provides a way to profile, support more personalized configuration, gowatch.yaml default configuration files in the current directory:

# gowatch.yml 配置示例

# 当前目录执行下生成的可执行文件的名字,默认是当前目录名
appname: "test"
# 指定编译后的目标文件目录
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: ""

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

Project address: https: //github.com/silenceper/gowatch

Join Golang interest groups, public concern number "learn program" and reply "into the group."

Concern "learn program" public number for more dry content! Learn program

Released three original articles · won praise 0 · Views 77

Guess you like

Origin blog.csdn.net/github_19391267/article/details/103956019