Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support gogc config fix #61 #62

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +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"
```
Expand Down
6 changes: 6 additions & 0 deletions README_ZH_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ build_tags: ""
# 是否禁止自动运行
disable_run: false

# 编译时使用GOGC,false强制不使用,true根据环境变量配置来,默认使用
build_go_gc: false

# 日志级别, 支持 debug, info, warn, error, fatal
log_level: "debug"

```

## 微信公众号
Expand Down
2 changes: 2 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion gowatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,12 @@ func Autobuild(files []string) {
args = append(args, files...)

bcmd := exec.Command(cmdName, args...)
bcmd.Env = append(os.Environ(), "GOGC=off")
bcmd.Env = os.Environ()
if !cfg.BuildGOGC {
bcmd.Env = append(bcmd.Env, "GOGC=off")
} else {
bcmd.Env = append(bcmd.Env, "GOGC=on")
}
silenceper marked this conversation as resolved.
Show resolved Hide resolved
bcmd.Stdout = os.Stdout
bcmd.Stderr = os.Stderr
log.Infof("Build Args: %s %s", cmdName, strings.Join(args, " "))
Expand Down
3 changes: 3 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
`
Expand Down