From 553082256c9de585e46b92dc096b7b1959ca538b Mon Sep 17 00:00:00 2001 From: Leelmes Date: Thu, 29 Feb 2024 22:44:20 +0800 Subject: [PATCH 1/7] disable go gc --- go.mod | 2 +- gowatch.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index d6d3b32..d366fb4 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/silenceper/gowatch +module github.com/flyhope/gowatch go 1.14 diff --git a/gowatch.go b/gowatch.go index 4c6589c..5d9d39e 100644 --- a/gowatch.go +++ b/gowatch.go @@ -152,7 +152,8 @@ func Autobuild(files []string) { args = append(args, files...) bcmd := exec.Command(cmdName, args...) - bcmd.Env = append(os.Environ(), "GOGC=off") + bcmd.Env = os.Environ() + //bcmd.Env = append(os.Environ(), "GOGC=off") bcmd.Stdout = os.Stdout bcmd.Stderr = os.Stderr log.Infof("Build Args: %s %s", cmdName, strings.Join(args, " ")) From cc86d37089df9173b67fcbd9ce49bb40b613a2d7 Mon Sep 17 00:00:00 2001 From: Leelmes Date: Fri, 1 Mar 2024 07:27:37 +0800 Subject: [PATCH 2/7] build go gc use config --- config.go | 2 ++ gowatch.go | 4 +++- main.go | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/config.go b/config.go index 45083dc..2c4c628 100644 --- a/config.go +++ b/config.go @@ -25,6 +25,8 @@ type config struct { CmdArgs []string `yaml:"cmd_args"` // Additional parameters during build BuildArgs []string `yaml:"build_args"` + // use GOGC on build + BuildGOGC bool `yaml:"build_go_gc"` // Environment variables added when running the application Envs []string `yaml:"envs"` // Specify whether the files in the vendor directory are also watched diff --git a/gowatch.go b/gowatch.go index 5d9d39e..2dd7813 100644 --- a/gowatch.go +++ b/gowatch.go @@ -153,7 +153,9 @@ func Autobuild(files []string) { bcmd := exec.Command(cmdName, args...) bcmd.Env = os.Environ() - //bcmd.Env = append(os.Environ(), "GOGC=off") + if !cfg.BuildGOGC { + bcmd.Env = append(bcmd.Env, "GOGC=off") + } bcmd.Stdout = os.Stdout bcmd.Stderr = os.Stderr log.Infof("Build Args: %s %s", cmdName, strings.Join(args, " ")) diff --git a/main.go b/main.go index da1abb0..7f92ba1 100644 --- a/main.go +++ b/main.go @@ -96,6 +96,9 @@ build_tags: "" # Whether to prohibit automatic operation disable_run: false +# use GOGC on build +build_go_gc: false + # log level, support debug, info, warn, error, fatal log_level: "debug" ` From 17f6f1c3ca14be7a3a9de7a8eb498dc1e7f41b55 Mon Sep 17 00:00:00 2001 From: Leelmes Date: Fri, 1 Mar 2024 07:31:44 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E6=9B=B4=E6=96=B0README?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 9 +++------ README_ZH_CN.md | 12 ++++++------ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 381cff8..ce5515b 100644 --- a/README.md +++ b/README.md @@ -110,12 +110,9 @@ build_tags: "" # Whether to prohibit automatic operation disable_run: false +# use GOGC on build +build_go_gc: false + # log level, support debug, info, warn, error, fatal log_level: "debug" ``` - -## Author -[@silenceper](http://silenceper.com) - - ->Inspired by [bee](https://github.com/beego/bee) diff --git a/README_ZH_CN.md b/README_ZH_CN.md index 250e82f..14716ec 100644 --- a/README_ZH_CN.md +++ b/README_ZH_CN.md @@ -12,7 +12,7 @@ Go 程序热编译工具,提升开发效率 使用 `go insall` 命令安装 `gowatch` ```go -go install github.com/silenceper/gowatch@latest +go install github.com/flyhope/gowatch@latest ``` 安装完成之后,即可使用`gowatch`命令,在当前文件执行: @@ -94,11 +94,11 @@ build_tags: "" # 是否禁止自动运行 disable_run: false -``` +# 编译时使用GOGC,false强制不使用,true根据环境变量配置来,默认使用 +build_go_gc: false -## 微信公众号 -![关注公众号入群交流](https://silenceper.oss-cn-beijing.aliyuncs.com/qrcode/qr_code_study_program_258.jpg) ->关注公众号并回复“入群” +# 日志级别, 支持 debug, info, warn, error, fatal +log_level: "debug" +``` ->Inspired by [bee](https://github.com/beego/bee) From 07cc561912938a1a24f42efc71e6fecda8e02a52 Mon Sep 17 00:00:00 2001 From: Leelmes Date: Fri, 1 Mar 2024 07:39:17 +0800 Subject: [PATCH 4/7] revert silenceper --- README.md | 6 ++++++ README_ZH_CN.md | 10 +++++++++- go.mod | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ce5515b..fa042b0 100644 --- a/README.md +++ b/README.md @@ -116,3 +116,9 @@ build_go_gc: false # log level, support debug, info, warn, error, fatal log_level: "debug" ``` + +## Author +[@silenceper](http://silenceper.com) + + +>Inspired by [bee](https://github.com/beego/bee) diff --git a/README_ZH_CN.md b/README_ZH_CN.md index 14716ec..baf8d33 100644 --- a/README_ZH_CN.md +++ b/README_ZH_CN.md @@ -12,7 +12,7 @@ Go 程序热编译工具,提升开发效率 使用 `go insall` 命令安装 `gowatch` ```go -go install github.com/flyhope/gowatch@latest +go install github.com/silenceper/gowatch@latest ``` 安装完成之后,即可使用`gowatch`命令,在当前文件执行: @@ -102,3 +102,11 @@ log_level: "debug" ``` + +## 微信公众号 +![关注公众号入群交流](https://silenceper.oss-cn-beijing.aliyuncs.com/qrcode/qr_code_study_program_258.jpg) +>关注公众号并回复“入群” + + +>Inspired by [bee](https://github.com/beego/bee) + diff --git a/go.mod b/go.mod index d366fb4..d6d3b32 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/flyhope/gowatch +module github.com/silenceper/gowatch go 1.14 From 8d0f5243d29790037ab3d69bc9b95545d05b7efe Mon Sep 17 00:00:00 2001 From: Leelmes Date: Fri, 1 Mar 2024 07:40:49 +0800 Subject: [PATCH 5/7] format README --- README_ZH_CN.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README_ZH_CN.md b/README_ZH_CN.md index baf8d33..46e24ea 100644 --- a/README_ZH_CN.md +++ b/README_ZH_CN.md @@ -102,11 +102,9 @@ log_level: "debug" ``` - ## 微信公众号 ![关注公众号入群交流](https://silenceper.oss-cn-beijing.aliyuncs.com/qrcode/qr_code_study_program_258.jpg) >关注公众号并回复“入群” >Inspired by [bee](https://github.com/beego/bee) - From eb524c0f88d0ef6570856465d0c714ed5714c0fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=9E=A8=E7=85=8A?= Date: Fri, 1 Mar 2024 17:50:13 +0800 Subject: [PATCH 6/7] set env GOGC=on when config BuildGOGC=true --- gowatch.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gowatch.go b/gowatch.go index 2dd7813..de711d3 100644 --- a/gowatch.go +++ b/gowatch.go @@ -12,7 +12,6 @@ import ( "time" "github.com/fsnotify/fsnotify" - "github.com/mitchellh/go-ps" "github.com/silenceper/log" ) @@ -155,6 +154,8 @@ func Autobuild(files []string) { bcmd.Env = os.Environ() if !cfg.BuildGOGC { bcmd.Env = append(bcmd.Env, "GOGC=off") + } else { + bcmd.Env = append(bcmd.Env, "GOGC=on") } bcmd.Stdout = os.Stdout bcmd.Stderr = os.Stderr From a52f9be105e9ee2f067439e4bca05db0ab9bc3f6 Mon Sep 17 00:00:00 2001 From: Leelmes Date: Mon, 4 Mar 2024 21:21:06 +0800 Subject: [PATCH 7/7] revert import "github.com/mitchellh/go-ps" --- gowatch.go | 1 + 1 file changed, 1 insertion(+) diff --git a/gowatch.go b/gowatch.go index de711d3..f4d03a3 100644 --- a/gowatch.go +++ b/gowatch.go @@ -12,6 +12,7 @@ import ( "time" "github.com/fsnotify/fsnotify" + "github.com/mitchellh/go-ps" "github.com/silenceper/log" )