1
0
mirror of https://github.com/astaxie/beego.git synced 2024-12-22 17:30:50 +00:00

gofmt and golint

This commit is contained in:
astaxie 2017-07-19 00:52:27 +08:00
parent aa3d6c5363
commit 4fc95b0d69
6 changed files with 44 additions and 51 deletions

View File

@ -55,6 +55,7 @@ type ControllerComments struct {
MethodParams []*param.MethodParam
}
// ControllerCommentsSlice implements the sort interface
type ControllerCommentsSlice []ControllerComments
func (p ControllerCommentsSlice) Len() int { return len(p) }

View File

@ -9,7 +9,7 @@ import (
type graceConn struct {
net.Conn
server *Server
m sync.Mutex
m sync.Mutex
closed bool
}
@ -26,7 +26,7 @@ func (c *graceConn) Close() (err error) {
}
}
}()
c.m.Lock()
if c.closed {
c.m.Unlock()

View File

@ -71,6 +71,7 @@ func (m *Migration) CreateTable(tablename, engine, charset string, p ...func())
m.ModifyType = "create"
}
// AlterTable set the ModifyType to alter
func (m *Migration) AlterTable(tablename string) {
m.TableName = tablename
m.ModifyType = "alter"

View File

@ -1,41 +1,32 @@
/* Package migration enables you to generate migrations back and forth. It generates both migrations.
//Creates a table
m.CreateTable("tablename","InnoDB","utf8");
//Alter a table
m.AlterTable("tablename")
//Standard Column Methods
* SetDataType
* SetNullable
* SetDefault
* SetUnsigned (use only on integer types unless produces error)
//Sets a primary column, multiple calls allowed, standard column methods available
m.PriCol("id").SetAuto(true).SetNullable(false).SetDataType("INT(10)").SetUnsigned(true)
//UniCol Can be used multiple times, allows standard Column methods. Use same "index" string to add to same index
m.UniCol("index","column")
//Standard Column Initialisation, can call .Remove() after NewCol("") on alter to remove
m.NewCol("name").SetDataType("VARCHAR(255) COLLATE utf8_unicode_ci").SetNullable(false)
m.NewCol("value").SetDataType("DOUBLE(8,2)").SetNullable(false)
//Rename Columns , only use with Alter table, doesn't works with Create, prefix standard column methods with "Old" to
//create a true reversible migration eg: SetOldDataType("DOUBLE(12,3)")
m.RenameColumn("from","to")...
//Foreign Columns, single columns are only supported, SetOnDelete & SetOnUpdate are available, call appropriately.
//Supports standard column methods, automatic reverse.
m.ForeignCol("local_col","foreign_col","foreign_table")
*/
// Package migration enables you to generate migrations back and forth. It generates both migrations.
//
// //Creates a table
// m.CreateTable("tablename","InnoDB","utf8");
//
// //Alter a table
// m.AlterTable("tablename")
//
// Standard Column Methods
// * SetDataType
// * SetNullable
// * SetDefault
// * SetUnsigned (use only on integer types unless produces error)
//
// //Sets a primary column, multiple calls allowed, standard column methods available
// m.PriCol("id").SetAuto(true).SetNullable(false).SetDataType("INT(10)").SetUnsigned(true)
//
// //UniCol Can be used multiple times, allows standard Column methods. Use same "index" string to add to same index
// m.UniCol("index","column")
//
// //Standard Column Initialisation, can call .Remove() after NewCol("") on alter to remove
// m.NewCol("name").SetDataType("VARCHAR(255) COLLATE utf8_unicode_ci").SetNullable(false)
// m.NewCol("value").SetDataType("DOUBLE(8,2)").SetNullable(false)
//
// //Rename Columns , only use with Alter table, doesn't works with Create, prefix standard column methods with "Old" to
// //create a true reversible migration eg: SetOldDataType("DOUBLE(12,3)")
// m.RenameColumn("from","to")...
//
// //Foreign Columns, single columns are only supported, SetOnDelete & SetOnUpdate are available, call appropriately.
// //Supports standard column methods, automatic reverse.
// m.ForeignCol("local_col","foreign_col","foreign_table")
package migration

View File

@ -45,8 +45,8 @@ var (
"Valid": true,
"NoMatch": true,
}
Int64On32Err = fmt.Errorf("not support int64 on 32-bit platform")
// ErrInt64On32 show 32 bit platform not support int64
ErrInt64On32 = fmt.Errorf("not support int64 on 32-bit platform")
)
func init() {
@ -255,7 +255,7 @@ func parseParam(t reflect.Type, s string) (i interface{}, err error) {
i, err = strconv.Atoi(s)
case reflect.Int64:
if wordsize == 32 {
return nil, Int64On32Err
return nil, ErrInt64On32
}
i, err = strconv.ParseInt(s, 10, 64)
case reflect.Int32:

View File

@ -25,12 +25,12 @@ import (
// CanSkipFuncs will skip valid if RequiredFirst is true and the struct field's value is empty
var CanSkipFuncs = map[string]struct{}{
"Email": struct{}{},
"IP": struct{}{},
"Mobile": struct{}{},
"Tel": struct{}{},
"Phone": struct{}{},
"ZipCode": struct{}{},
"Email": {},
"IP": {},
"Mobile": {},
"Tel": {},
"Phone": {},
"ZipCode": {},
}
// MessageTmpls store commond validate template