Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
beego
Commits
4fc95b0d
Commit
4fc95b0d
authored
Jul 18, 2017
by
astaxie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gofmt and golint
parent
aa3d6c53
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
44 additions
and
51 deletions
+44
-51
controller.go
controller.go
+1
-0
conn.go
grace/conn.go
+2
-2
ddl.go
migration/ddl.go
+1
-0
doc.go
migration/doc.go
+31
-40
util.go
validation/util.go
+3
-3
validators.go
validation/validators.go
+6
-6
No files found.
controller.go
View file @
4fc95b0d
...
...
@@ -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
)
}
...
...
grace/conn.go
View file @
4fc95b0d
...
...
@@ -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
()
...
...
migration/ddl.go
View file @
4fc95b0d
...
...
@@ -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"
...
...
migration/doc.go
View file @
4fc95b0d
/* 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
validation/util.go
View file @
4fc95b0d
...
...
@@ -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
:
...
...
validation/validators.go
View file @
4fc95b0d
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment