From ea3d0690cf5218db7b6154f6225f699b2ded1cf7 Mon Sep 17 00:00:00 2001 From: astaxie Date: Sat, 29 Apr 2017 09:13:28 +0800 Subject: [PATCH] golint --- policy.go | 4 ++-- template.go | 1 + template_test.go | 4 ++-- templatefunc.go | 6 +++--- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/policy.go b/policy.go index 2b91fdcc..ab23f927 100644 --- a/policy.go +++ b/policy.go @@ -23,7 +23,7 @@ import ( // PolicyFunc defines a policy function which is invoked before the controller handler is executed. type PolicyFunc func(*context.Context) -// FindRouter Find Router info for URL +// FindPolicy Find Router info for URL func (p *ControllerRegister) FindPolicy(cont *context.Context) []PolicyFunc { var urlPath = cont.Input.URL() if !BConfig.RouterCaseSensitive { @@ -71,7 +71,7 @@ func (p *ControllerRegister) addToPolicy(method, pattern string, r ...PolicyFunc } } -// Register new policy in beego +// Policy Register new policy in beego func Policy(pattern, method string, policy ...PolicyFunc) { BeeApp.Handlers.addToPolicy(method, pattern, policy...) } diff --git a/template.go b/template.go index 73a14977..d4859cd7 100644 --- a/template.go +++ b/template.go @@ -365,6 +365,7 @@ func DelStaticPath(url string) *App { return BeeApp } +// AddTemplateEngine add a new templatePreProcessor which support extension func AddTemplateEngine(extension string, fn templatePreProcessor) *App { AddTemplateExt(extension) beeTemplateEngines[extension] = fn diff --git a/template_test.go b/template_test.go index 16967382..2153ef72 100644 --- a/template_test.go +++ b/template_test.go @@ -159,7 +159,7 @@ var add = `{{ template "layout_blog.tpl" . }} {{ end}}` -var layout_blog = ` +var layoutBlog = ` Lin Li @@ -231,7 +231,7 @@ func TestTemplateLayout(t *testing.T) { if k == 0 { f.WriteString(add) } else if k == 1 { - f.WriteString(layout_blog) + f.WriteString(layoutBlog) } f.Close() } diff --git a/templatefunc.go b/templatefunc.go index 4fdc936d..a6f9c961 100644 --- a/templatefunc.go +++ b/templatefunc.go @@ -507,9 +507,9 @@ func parseFormTag(fieldT reflect.StructField) (label, name, fType string, id str class = fieldT.Tag.Get("class") required = false - required_field := fieldT.Tag.Get("required") - if required_field != "-" && required_field != "" { - required, _ = strconv.ParseBool(required_field) + requiredField := fieldT.Tag.Get("required") + if requiredField != "-" && requiredField != "" { + required, _ = strconv.ParseBool(requiredField) } switch len(tags) {