Skip to content

Commit

Permalink
Merge pull request beego#2940 from BorisBorshevsky/golint
Browse files Browse the repository at this point in the history
fix golint comments
  • Loading branch information
astaxie authored Nov 26, 2017
2 parents a5dd5d1 + df37739 commit 9710d9e
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 13 deletions.
1 change: 1 addition & 0 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func NewApp() *App {
return app
}

// MiddleWare function for http.Handler
type MiddleWare func(http.Handler) http.Handler

// Run beego application.
Expand Down
1 change: 1 addition & 0 deletions beego.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func Run(params ...string) {
BeeApp.Run()
}

// RunWithMiddleWares Run beego application with middlewares.
func RunWithMiddleWares(addr string, mws ...MiddleWare) {
initBeforeHTTPRun()

Expand Down
3 changes: 2 additions & 1 deletion grace/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "" {
Expand Down
8 changes: 5 additions & 3 deletions logs/accesslog.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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"`
}

Expand All @@ -60,6 +61,7 @@ func disableEscapeHTML(i interface{}) {
}
}

// AccessLog - Format and print access log.
func AccessLog(r *AccessLogRecord, format string) {
var msg string

Expand All @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions router.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions template.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand Down
6 changes: 3 additions & 3 deletions unregroute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 := ""
Expand Down

0 comments on commit 9710d9e

Please sign in to comment.