1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 14:20:54 +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 MethodParams []*param.MethodParam
} }
// ControllerCommentsSlice implements the sort interface
type ControllerCommentsSlice []ControllerComments type ControllerCommentsSlice []ControllerComments
func (p ControllerCommentsSlice) Len() int { return len(p) } func (p ControllerCommentsSlice) Len() int { return len(p) }

View File

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

View File

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

View File

@ -45,8 +45,8 @@ var (
"Valid": true, "Valid": true,
"NoMatch": true, "NoMatch": true,
} }
// ErrInt64On32 show 32 bit platform not support int64
Int64On32Err = fmt.Errorf("not support int64 on 32-bit platform") ErrInt64On32 = fmt.Errorf("not support int64 on 32-bit platform")
) )
func init() { func init() {
@ -255,7 +255,7 @@ func parseParam(t reflect.Type, s string) (i interface{}, err error) {
i, err = strconv.Atoi(s) i, err = strconv.Atoi(s)
case reflect.Int64: case reflect.Int64:
if wordsize == 32 { if wordsize == 32 {
return nil, Int64On32Err return nil, ErrInt64On32
} }
i, err = strconv.ParseInt(s, 10, 64) i, err = strconv.ParseInt(s, 10, 64)
case reflect.Int32: 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 // CanSkipFuncs will skip valid if RequiredFirst is true and the struct field's value is empty
var CanSkipFuncs = map[string]struct{}{ var CanSkipFuncs = map[string]struct{}{
"Email": struct{}{}, "Email": {},
"IP": struct{}{}, "IP": {},
"Mobile": struct{}{}, "Mobile": {},
"Tel": struct{}{}, "Tel": {},
"Phone": struct{}{}, "Phone": {},
"ZipCode": struct{}{}, "ZipCode": {},
} }
// MessageTmpls store commond validate template // MessageTmpls store commond validate template