Apply goimports' modifications

This commit is contained in:
Jihoon Seo
2021-01-28 13:42:03 +09:00
parent 2bb6c45786
commit 113b90531c
34 changed files with 57 additions and 67 deletions

View File

@@ -19,8 +19,6 @@ import (
"sync"
)
// A Code is an unsigned 32-bit error code as defined in the beego spec.
type Code interface {
Code() uint32
@@ -38,9 +36,9 @@ var defaultCodeRegistry = &codeRegistry{
// desc could be markdown doc
func DefineCode(code uint32, module string, name string, desc string) Code {
res := &codeDefinition{
code: code,
code: code,
module: module,
desc: desc,
desc: desc,
}
defaultCodeRegistry.lock.Lock()
defer defaultCodeRegistry.lock.Unlock()
@@ -53,11 +51,10 @@ func DefineCode(code uint32, module string, name string, desc string) Code {
}
type codeRegistry struct {
lock sync.RWMutex
lock sync.RWMutex
codes map[uint32]*codeDefinition
}
func (cr *codeRegistry) Get(code uint32) (Code, bool) {
cr.lock.RLock()
defer cr.lock.RUnlock()
@@ -66,13 +63,12 @@ func (cr *codeRegistry) Get(code uint32) (Code, bool) {
}
type codeDefinition struct {
code uint32
code uint32
module string
desc string
name string
desc string
name string
}
func (c *codeDefinition) Name() string {
return c.name
}
@@ -88,4 +84,3 @@ func (c *codeDefinition) Module() string {
func (c *codeDefinition) Desc() string {
return c.desc
}

View File

@@ -21,7 +21,7 @@ import (
// pre define code
// Unknown indicates got some error which is not defined
var Unknown = DefineCode(5000001, "error", "Unknown",fmt.Sprintf(`
var Unknown = DefineCode(5000001, "error", "Unknown", fmt.Sprintf(`
Unknown error code. Usually you will see this code in three cases:
1. You forget to define Code or function DefineCode not being executed;
2. This is not Beego's error but you call FromError();
@@ -49,4 +49,3 @@ func goCodeBlock(code string) string {
func codeBlock(lan string, code string) string {
return fmt.Sprintf("```%s\n%s\n```", lan, code)
}