Skip to content

Commit

Permalink
make golint happy
Browse files Browse the repository at this point in the history
  • Loading branch information
astaxie committed Sep 8, 2015
1 parent 61570ac commit 67b36d7
Show file tree
Hide file tree
Showing 13 changed files with 94 additions and 88 deletions.
4 changes: 2 additions & 2 deletions controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ type ControllerInterface interface {
Options()
Finish()
Render() error
XsrfToken() string
CheckXsrfCookie() bool
XSRFToken() string
CheckXSRFCookie() bool
HandlerFunc(fn string) bool
URLMapping()
}
Expand Down
2 changes: 1 addition & 1 deletion doc.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
Package beego provide a MVC framework
beego: an open-source, high-performance, modular, full-stack web framework
It is used for rapid development of RESTful APIs, web apps and backend services in Go.
Expand All @@ -14,4 +15,3 @@ beego is inspired by Tornado, Sinatra and Flask with the added benefit of some G
more infomation: http://beego.me
*/
package beego

9 changes: 5 additions & 4 deletions docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,21 @@ import (
"github.com/astaxie/beego/context"
)

var GlobalDocApi map[string]interface{}
// GlobalDocAPI store the swagger api documents
var GlobalDocAPI map[string]interface{}

func init() {
if EnableDocs {
GlobalDocApi = make(map[string]interface{})
GlobalDocAPI = make(map[string]interface{})
}
}

func serverDocs(ctx *context.Context) {
var obj interface{}
if splat := ctx.Input.Param(":splat"); splat == "" {
obj = GlobalDocApi["Root"]
obj = GlobalDocAPI["Root"]
} else {
if v, ok := GlobalDocApi[splat]; ok {
if v, ok := GlobalDocAPI[splat]; ok {
obj = v
}
}
Expand Down
6 changes: 3 additions & 3 deletions error.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ func gatewayTimeout(rw http.ResponseWriter, r *http.Request) {
// usage:
// beego.ErrorHandler("404",NotFound)
// beego.ErrorHandler("500",InternalServerError)
func Errorhandler(code string, h http.HandlerFunc) *App {
func ErrorHandler(code string, h http.HandlerFunc) *App {
errinfo := &errorInfo{}
errinfo.errorType = errorTypeHandler
errinfo.handler = h
Expand All @@ -373,7 +373,7 @@ func Errorhandler(code string, h http.HandlerFunc) *App {

// ErrorController registers ControllerInterface to each http err code string.
// usage:
// beego.ErrorHandler(&controllers.ErrorController{})
// beego.ErrorController(&controllers.ErrorController{})
func ErrorController(c ControllerInterface) *App {
reflectVal := reflect.ValueOf(c)
rt := reflectVal.Type()
Expand Down Expand Up @@ -431,7 +431,7 @@ func executeError(err *errorInfo, ctx *context.Context, code int) {

execController.URLMapping()

in := make([]reflect.Value, 0)
var in []reflect.Value
method := vc.MethodByName(err.method)
method.Call(in)

Expand Down
3 changes: 1 addition & 2 deletions filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ func (f *FilterRouter) ValidRouter(url string) (bool, map[string]string) {
}
if isok, ok := isok.(bool); ok {
return isok, params
} else {
return false, nil
}
return false, nil
}
2 changes: 1 addition & 1 deletion flash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (t *TestFlashController) TestWriteFlash() {
flash.Notice("TestFlashString")
flash.Store(&t.Controller)
// we choose to serve json because we don't want to load a template html file
t.ServeJson(true)
t.ServeJSON(true)
}

func TestFlashHeader(t *testing.T) {
Expand Down
20 changes: 10 additions & 10 deletions hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,41 +19,41 @@ func registerMime() error {
// register default error http handlers, 404,401,403,500 and 503.
func registerDefaultErrorHandler() error {
if _, ok := ErrorMaps["401"]; !ok {
Errorhandler("401", unauthorized)
ErrorHandler("401", unauthorized)
}

if _, ok := ErrorMaps["402"]; !ok {
Errorhandler("402", paymentRequired)
ErrorHandler("402", paymentRequired)
}

if _, ok := ErrorMaps["403"]; !ok {
Errorhandler("403", forbidden)
ErrorHandler("403", forbidden)
}

if _, ok := ErrorMaps["404"]; !ok {
Errorhandler("404", notFound)
ErrorHandler("404", notFound)
}

if _, ok := ErrorMaps["405"]; !ok {
Errorhandler("405", methodNotAllowed)
ErrorHandler("405", methodNotAllowed)
}

if _, ok := ErrorMaps["500"]; !ok {
Errorhandler("500", internalServerError)
ErrorHandler("500", internalServerError)
}
if _, ok := ErrorMaps["501"]; !ok {
Errorhandler("501", notImplemented)
ErrorHandler("501", notImplemented)
}
if _, ok := ErrorMaps["502"]; !ok {
Errorhandler("502", badGateway)
ErrorHandler("502", badGateway)
}

if _, ok := ErrorMaps["503"]; !ok {
Errorhandler("503", serviceUnavailable)
ErrorHandler("503", serviceUnavailable)
}

if _, ok := ErrorMaps["504"]; !ok {
Errorhandler("504", gatewayTimeout)
ErrorHandler("504", gatewayTimeout)
}
return nil
}
Expand Down
15 changes: 9 additions & 6 deletions log.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@ const (
LevelDebug
)

// SetLogLevel sets the global log level used by the simple
// logger.
// SetLevel sets the global log level used by the simple logger.
func SetLevel(l int) {
BeeLogger.SetLevel(l)
}

// SetLogFuncCall set the CallDepth, default is 3
func SetLogFuncCall(b bool) {
BeeLogger.EnableFuncCallDepth(b)
BeeLogger.SetLogFuncCallDepth(3)
}

// logger references the used application logger.
// BeeLogger references the used application logger.
var BeeLogger *logs.BeeLogger

// SetLogger sets a new logger.
Expand All @@ -55,10 +55,12 @@ func SetLogger(adaptername string, config string) error {
return nil
}

// Emergency logs a message at emergency level.
func Emergency(v ...interface{}) {
BeeLogger.Emergency(generateFmtStr(len(v)), v...)
}

// Alert logs a message at alert level.
func Alert(v ...interface{}) {
BeeLogger.Alert(generateFmtStr(len(v)), v...)
}
Expand All @@ -78,21 +80,22 @@ func Warning(v ...interface{}) {
BeeLogger.Warning(generateFmtStr(len(v)), v...)
}

// compatibility alias for Warning()
// Warn compatibility alias for Warning()
func Warn(v ...interface{}) {
BeeLogger.Warn(generateFmtStr(len(v)), v...)
}

// Notice logs a message at notice level.
func Notice(v ...interface{}) {
BeeLogger.Notice(generateFmtStr(len(v)), v...)
}

// Info logs a message at info level.
// Informational logs a message at info level.
func Informational(v ...interface{}) {
BeeLogger.Informational(generateFmtStr(len(v)), v...)
}

// compatibility alias for Warning()
// Info compatibility alias for Warning()
func Info(v ...interface{}) {
BeeLogger.Info(generateFmtStr(len(v)), v...)
}
Expand Down
6 changes: 4 additions & 2 deletions memzipfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ import (
"time"
)

var gmfim map[string]*memFileInfo = make(map[string]*memFileInfo)
var lock sync.RWMutex
var (
gmfim = make(map[string]*memFileInfo)
lock sync.RWMutex
)

// OpenMemZipFile returns MemFile object with a compressed static file.
// it's used for serve static file if gzip enable.
Expand Down
2 changes: 1 addition & 1 deletion mime.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

package beego

var mimemaps map[string]string = map[string]string{
var mimemaps = map[string]string{
".3dm": "x-world/x-3dmf",
".3dmf": "x-world/x-3dmf",
".7z": "application/x-7z-compressed",
Expand Down
Loading

0 comments on commit 67b36d7

Please sign in to comment.