Giter Club home page Giter Club logo

gobuild's Introduction

gobuild

Latest Release Test PkgGoDev Go version License codecov

gobuild 是一个简单的 Go 代码热编译工具。 会实时监控指定目录下的文件变化(重命名,删除,创建,添加),并编译和运行程序。

  • 采用配置文件,表达更加方便和直观;
  • 自动生成配置文件;
  • 自动监视 go.mod 中的 Replace 目录;
  • 本地化支持;

命令行语法

主要包含了 watch 和 init 两个子命令。具体的子命令可以通过 gobuild help 查看。

init

初始化项目,添加项目的必备的文件,比如热编译的配置文件 .gobuild.yaml。 如果是空目录,还会顺带初始化 go.mod 等文件。

gobuild init github.com/owner/mod

watch

监视文件并进行热编译,热编译的配置项从当前目录下的 .gobuild.yaml 加载。

gobuild watch [options]

配置文件

配置文件为当前目录下的 .gobuild.yaml,可由 gobuild init 子命令生成,包含了以下字段:

字段 类型 描述
main string 指定需要编译的文件,如果为空表示当前目录。
output string 指定可执行文件输出的文件路径
args string 传递给编译器的参数
exts []string 指定监视的文件扩展名,如果包含了 *,表示所有文件类型,包括没有扩展名的。
appArgs string 传递给编译成功后的程序的参数
freq duration 监视器的更新频率
excludes []string 忽略的文件,glob 格式,高于 exts 配置项。

安装

macOS 和 linux 用户可以直接使用 brew 进行安装:

brew tap caixw/brew
brew install caixw/brew/gobuild

常用平台可以从 https://github.com/caixw/gobuild/releases 下载,并将二进制文件放入 PATH 即可。

如果不存在你当前平台的二进制,可以自己编译:

git clone https://github.com/caixw/gobuild.git
cd gobuild
./build.sh

版权

本项目采用 MIT 开源授权许可证,完整的授权说明可在 LICENSE 文件中找到。

gobuild's People

Contributors

caixw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

gobuild's Issues

减少too many open files错误的发生

目前想到的解决方案如下:

  • 遍历监视目录下的所有文件,若该目录下没有需要监视的文件类型,则放弃对整个目录的监视,这样后续在该目录添加的文件可能监视不到。
  • 提供额外参数用于指定不需要监视的目录,但是这样不好解决多监视多目录情况下的从属问题。

长时间运行之后,出现too many open files错误

2015-07-05 21:36:40 [INFO] watcher.Events:触发编译事件: "../modules/admin/route.go": RENAME
2015-07-05 21:36:40 [INFO] 编译代码...
go build github.com/issue9/orm/forward: /Applications/Go/pkg/tool/darwin_amd64/6g: fork/exec /Applications/Go/pkg/tool/darwin_amd64/6g: too many open files
go build github.com/issue9/web/modules/admin/models: /Applications/Go/pkg/tool/darwin_amd64/6g: fork/exec /Applications/Go/pkg/tool/darwin_amd64/6g: too many open files
2015-07-05 21:36:40 [ERROR] 编译失败: exit status 1

不编译的情况下,重启程序

有时候可能仅仅是改变了配置文件,代码本身没有动,此时若要自动重启程序,只能将该文件纳入监视范围。有没有可能通过客房端输入某个参数重启程序。

我想加入一些go tool

你好,
我想编译之前加入goimports和golint,可以pr过来吗?

最好,非常感谢您为gobuild做的工作

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.