From df37739c7d8433c2b230fe888183f3c86225ac6f Mon Sep 17 00:00:00 2001 From: BorisBorshevsky Date: Sat, 25 Nov 2017 19:16:37 +0200 Subject: [PATCH] fix golint comments --- app.go | 1 + beego.go | 1 + grace/server.go | 3 ++- logs/accesslog.go | 8 +++++--- router.go | 6 +++--- template.go | 3 +-- unregroute_test.go | 6 +++--- validation/validation.go | 2 +- 8 files changed, 17 insertions(+), 13 deletions(-) diff --git a/app.go b/app.go index 3aade809..3687a30c 100644 --- a/app.go +++ b/app.go @@ -55,6 +55,7 @@ func NewApp() *App { return app } +// MiddleWare function for http.Handler type MiddleWare func(http.Handler) http.Handler // Run beego application. diff --git a/beego.go b/beego.go index 92aeef1e..55f2d7f2 100644 --- a/beego.go +++ b/beego.go @@ -67,6 +67,7 @@ func Run(params ...string) { BeeApp.Run() } +// RunWithMiddleWares Run beego application with middlewares. func RunWithMiddleWares(addr string, mws ...MiddleWare) { initBeforeHTTPRun() diff --git a/grace/server.go b/grace/server.go index dbce1ef0..513a52a9 100644 --- a/grace/server.go +++ b/grace/server.go @@ -131,7 +131,8 @@ func (srv *Server) ListenAndServeTLS(certFile, keyFile string) (err error) { return srv.Serve() } -//ListenAndServeMutualTLS +// ListenAndServeMutualTLS listens on the TCP network address srv.Addr and then calls +// Serve to handle requests on incoming mutual TLS connections. func (srv *Server) ListenAndServeMutualTLS(certFile, keyFile, trustFile string) (err error) { addr := srv.Addr if addr == "" { diff --git a/logs/accesslog.go b/logs/accesslog.go index c25d6e16..cf799dc1 100644 --- a/logs/accesslog.go +++ b/logs/accesslog.go @@ -27,6 +27,7 @@ const ( jsonFormat = "JSON_FORMAT" ) +// AccessLogRecord struct for holding access log data. type AccessLogRecord struct { RemoteAddr string `json:"remote_addr"` RequestTime time.Time `json:"request_time"` @@ -37,8 +38,8 @@ type AccessLogRecord struct { Status int `json:"status"` BodyBytesSent int64 `json:"body_bytes_sent"` ElapsedTime time.Duration `json:"elapsed_time"` - HttpReferrer string `json:"http_referrer"` - HttpUserAgent string `json:"http_user_agent"` + HTTPReferrer string `json:"http_referrer"` + HTTPUserAgent string `json:"http_user_agent"` RemoteUser string `json:"remote_user"` } @@ -60,6 +61,7 @@ func disableEscapeHTML(i interface{}) { } } +// AccessLog - Format and print access log. func AccessLog(r *AccessLogRecord, format string) { var msg string @@ -68,7 +70,7 @@ func AccessLog(r *AccessLogRecord, format string) { case apacheFormat: timeFormatted := r.RequestTime.Format("02/Jan/2006 03:04:05") msg = fmt.Sprintf(apacheFormatPattern, r.RemoteAddr, timeFormatted, r.Request, r.Status, r.BodyBytesSent, - r.ElapsedTime.Seconds(), r.HttpReferrer, r.HttpUserAgent) + r.ElapsedTime.Seconds(), r.HTTPReferrer, r.HTTPUserAgent) case jsonFormat: fallthrough default: diff --git a/router.go b/router.go index da558cde..c752eba0 100644 --- a/router.go +++ b/router.go @@ -915,10 +915,10 @@ Admin: Host: r.Host, Status: statusCode, ElapsedTime: timeDur, - HttpReferrer: r.Header.Get("Referer"), - HttpUserAgent: r.Header.Get("User-Agent"), + HTTPReferrer: r.Header.Get("Referer"), + HTTPUserAgent: r.Header.Get("User-Agent"), RemoteUser: r.Header.Get("Remote-User"), - BodyBytesSent: 0, //@todo this one is missing! + BodyBytesSent: 0, //@todo this one is missing! } logs.AccessLog(record, BConfig.Log.AccessLogsFormat) }else { diff --git a/template.go b/template.go index 41da7ad9..7adc0403 100644 --- a/template.go +++ b/template.go @@ -219,9 +219,8 @@ func BuildTemplate(dir string, files ...string) error { if err != nil { logs.Error("parse template err:", file, err) return err - } else { - beeTemplates[file] = t } + beeTemplates[file] = t templatesLock.Unlock() } } diff --git a/unregroute_test.go b/unregroute_test.go index 59936e6e..08b1b77b 100644 --- a/unregroute_test.go +++ b/unregroute_test.go @@ -72,7 +72,7 @@ func (tc *TestPostUnregController) GetFixedLevel2() { // should remain intact, and continue to serve the original content. func TestUnregisterFixedRouteRoot(t *testing.T) { - var method string = "GET" + var method = "GET" handler := NewControllerRegister() handler.Add("/", &TestPreUnregController{}, "get:GetFixedRoot") @@ -114,7 +114,7 @@ func TestUnregisterFixedRouteRoot(t *testing.T) { // should remain intact, and continue to serve the original content. func TestUnregisterFixedRouteLevel1(t *testing.T) { - var method string = "GET" + var method = "GET" handler := NewControllerRegister() handler.Add("/", &TestPreUnregController{}, "get:GetFixedRoot") @@ -164,7 +164,7 @@ func TestUnregisterFixedRouteLevel1(t *testing.T) { // should remain intact, and continue to serve the original content. func TestUnregisterFixedRouteLevel2(t *testing.T) { - var method string = "GET" + var method = "GET" handler := NewControllerRegister() handler.Add("/", &TestPreUnregController{}, "get:GetFixedRoot") diff --git a/validation/validation.go b/validation/validation.go index be56f13e..0d89be30 100644 --- a/validation/validation.go +++ b/validation/validation.go @@ -278,7 +278,7 @@ func (v *Validation) apply(chk Validator, obj interface{}) *Result { } } -// Add independent error message for key +// AddError adds independent error message for the provided key func (v *Validation) AddError(key, message string) { Name := key Field := ""