From 147e776afb205f7845a2326c24ab7c1fe57fe59b Mon Sep 17 00:00:00 2001 From: wangle <285273592@qq.com> Date: Mon, 27 Jul 2020 23:39:01 +0800 Subject: [PATCH] Formatting code --- internal/app/module/beegopro/render.go | 4 +--- internal/app/module/beegopro/util.go | 4 ++-- utils/utils.go | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/internal/app/module/beegopro/render.go b/internal/app/module/beegopro/render.go index 7fe55a2..7ca97ae 100644 --- a/internal/app/module/beegopro/render.go +++ b/internal/app/module/beegopro/render.go @@ -1,7 +1,6 @@ package beegopro import ( - "errors" "github.com/beego/bee/internal/pkg/system" beeLogger "github.com/beego/bee/logger" "github.com/davecgh/go-spew/spew" @@ -136,8 +135,7 @@ func (r *RenderFile) Exec(name string) { var bts []byte bts, err = format.Source([]byte(buf)) if err != nil { - err = errors.New("format buf error " + err.Error()) - return + beeLogger.Log.Warnf("format buf error %s", err.Error()) } output = bts } diff --git a/internal/app/module/beegopro/util.go b/internal/app/module/beegopro/util.go index 666bc45..eb23b75 100644 --- a/internal/app/module/beegopro/util.go +++ b/internal/app/module/beegopro/util.go @@ -58,12 +58,12 @@ func (c *RenderFile) write(filename string, buf []byte) (err error) { return } - output := []byte(buf) + var output []byte if c.Option.EnableFormat && filepath.Ext(filename) == ".go" { // format code var bts []byte - bts, err = format.Source([]byte(buf)) + bts, err = format.Source(buf) if err != nil { err = errors.New("format buf error " + err.Error()) return diff --git a/utils/utils.go b/utils/utils.go index 3f60fad..ac46062 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -522,7 +522,7 @@ func goGetBee() { select { case <-done: return - case <-time.After(time.Duration(30 * time.Second)): + case <-time.After(time.Second * 30): beeLogger.Log.Warn("Update Bee timeout!!!") } }