gofresh

command module
v0.0.0-...-8b53867 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2020 License: MIT Imports: 4 Imported by: 0

README

gofresh

golang 热编译工具,实时监测代码变动并编译运行. fork来源: https://github.com/gravityblast/fresh

用过很多热编译工具,各有各的坑,总之用起来问题不少,大多数坑在:

  • 编译后杀死原进程不及时,运行新程序时候导致端口占用
  • 要编译的包无法指定
  • 要编译的临时目录无法指定
  • 运行时参数无法指定
  • 监控文件无法灵活指定
  • 只编译不运行
  • 卡顿延迟,意外退出

综合以上毛病,亲身体验, 在原fresh 的项目基础上小改一番,用了2年感觉很丝滑

使用

1, 全局安装 gofresh 命令

go get -u github.com/jangozw/gofresh

2, 在你的项目跟目录添加一个 .gofresh 的配置文件:

详情见 .gofresh 内容

touch .gofresh

添加内容:


# 监控代码变动的目录 . 表示当前目录
watch_dir:          .

# 编译的文件
build_file :        cmd/app/main.go

# 存放编译文件的临时目录
tmp_path:          tmp

# 启动参数 模版: -p=conf/test.ini
run_arg:            -p=conf/test.ini

# 编译的二进制名称
build_name:        app-main-build

# 编译日志
build_log:         app-main-build-errors.log

# 监控的文件扩展名
valid_ext:         .go, .ini

# 这些扩展名的文件忽略
no_rebuild_ext:    .tpl, .tmpl, .html

# 忽略目录
ignored:           assets, tmp, deploy

# 监测到变动后编译延迟时间
build_delay:       600

colors:            1
log_color_main:    cyan
log_color_build:   yellow
log_color_runner:  green
log_color_watcher: magenta
log_color_app: green


3, 在项目根目录运行gofresh


gofresh

Documentation

Overview

Fresh is a command line tool that builds and (re)starts your web application everytime you save a go or template file.

If the web framework you are using supports the Fresh runner, it will show build errors on your browser.

It currently works with Traffic (https://github.com/pilu/traffic), Martini (https://github.com/codegangsta/martini) and gocraft/web (https://github.com/gocraft/web).

Fresh will watch for file events, and every time you create/modifiy/delete a file it will build and restart the application. If `go build` returns an error, it will logs it in the tmp folder.

Traffic (https://github.com/pilu/traffic) already has a middleware that shows the content of that file if it is present. This middleware is automatically added if you run a Traffic web app in dev mode with Fresh.

Directories

Path Synopsis
_examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL