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
aa8f7bc1
Commit
aa8f7bc1
authored
Apr 28, 2017
by
astaxie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix ineffectual
parent
3e29078f
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
35 additions
and
22 deletions
+35
-22
ini.go
config/ini.go
+4
-1
color_windows.go
logs/color_windows.go
+1
-1
file.go
logs/file.go
+6
-4
db.go
orm/db.go
+1
-1
db_mysql.go
orm/db_mysql.go
+1
-2
orm.go
orm/orm.go
+1
-1
orm_raw.go
orm/orm_raw.go
+1
-1
orm_test.go
orm/orm_test.go
+7
-0
sess_couchbase.go
session/couchbase/sess_couchbase.go
+3
-1
sess_test.go
session/sess_test.go
+1
-2
template.go
template.go
+2
-1
templatefunc_test.go
templatefunc_test.go
+5
-5
file.go
utils/file.go
+1
-1
util_test.go
validation/util_test.go
+1
-1
No files found.
config/ini.go
View file @
aa8f7bc1
...
...
@@ -325,7 +325,10 @@ func (c *IniConfigContainer) SaveConfigFile(filename string) (err error) {
// Get section or key comments. Fixed #1607
getCommentStr
:=
func
(
section
,
key
string
)
string
{
comment
,
ok
:=
""
,
false
var
(
comment
string
ok
bool
)
if
len
(
key
)
==
0
{
comment
,
ok
=
c
.
sectionComment
[
section
]
}
else
{
...
...
logs/color_windows.go
View file @
aa8f7bc1
...
...
@@ -361,7 +361,7 @@ func isParameterChar(b byte) bool {
}
func
(
cw
*
ansiColorWriter
)
Write
(
p
[]
byte
)
(
int
,
error
)
{
r
,
nw
,
first
,
last
:=
0
,
0
,
0
,
0
var
r
,
nw
,
first
,
last
int
if
cw
.
mode
!=
DiscardNonColorEscSeq
{
cw
.
state
=
outsideCsiCode
cw
.
resetBuffer
()
...
...
logs/file.go
View file @
aa8f7bc1
...
...
@@ -259,7 +259,7 @@ func (w *fileLogWriter) doRotate(logTime time.Time) error {
}
// return error if the last file checked still existed
if
err
==
nil
{
return
fmt
.
Errorf
(
"Rotate: Cannot find free log number to rename %s
\n
"
,
w
.
Filename
)
return
fmt
.
Errorf
(
"Rotate: Cannot find free log number to rename %s"
,
w
.
Filename
)
}
// close fileWriter before rename
...
...
@@ -268,6 +268,9 @@ func (w *fileLogWriter) doRotate(logTime time.Time) error {
// Rename the file to its new found name
// even if occurs error,we MUST guarantee to restart new logger
err
=
os
.
Rename
(
w
.
Filename
,
fName
)
if
err
!=
nil
{
goto
RESTART_LOGGER
}
err
=
os
.
Chmod
(
fName
,
os
.
FileMode
(
0440
))
// re-start logger
RESTART_LOGGER
:
...
...
@@ -276,13 +279,12 @@ RESTART_LOGGER:
go
w
.
deleteOldLog
()
if
startLoggerErr
!=
nil
{
return
fmt
.
Errorf
(
"Rotate StartLogger: %s
\n
"
,
startLoggerErr
)
return
fmt
.
Errorf
(
"Rotate StartLogger: %s"
,
startLoggerErr
)
}
if
err
!=
nil
{
return
fmt
.
Errorf
(
"Rotate: %s
\n
"
,
err
)
return
fmt
.
Errorf
(
"Rotate: %s"
,
err
)
}
return
nil
}
func
(
w
*
fileLogWriter
)
deleteOldLog
()
{
...
...
orm/db.go
View file @
aa8f7bc1
...
...
@@ -1110,7 +1110,7 @@ func (d *dbBase) Count(q dbQuerier, qs *querySet, mi *modelInfo, cond *Condition
// generate sql with replacing operator string placeholders and replaced values.
func
(
d
*
dbBase
)
GenerateOperatorSQL
(
mi
*
modelInfo
,
fi
*
fieldInfo
,
operator
string
,
args
[]
interface
{},
tz
*
time
.
Location
)
(
string
,
[]
interface
{})
{
sql
:=
""
var
sql
string
params
:=
getFlatParams
(
fi
,
args
,
tz
)
if
len
(
params
)
==
0
{
...
...
orm/db_mysql.go
View file @
aa8f7bc1
...
...
@@ -103,8 +103,7 @@ func (d *dbBaseMysql) IndexExists(db dbQuerier, table string, name string) bool
// If no will insert
// Add "`" for mysql sql building
func
(
d
*
dbBaseMysql
)
InsertOrUpdate
(
q
dbQuerier
,
mi
*
modelInfo
,
ind
reflect
.
Value
,
a
*
alias
,
args
...
string
)
(
int64
,
error
)
{
iouStr
:=
""
var
iouStr
string
argsMap
:=
map
[
string
]
string
{}
iouStr
=
"ON DUPLICATE KEY UPDATE"
...
...
orm/orm.go
View file @
aa8f7bc1
...
...
@@ -420,7 +420,7 @@ func (o *orm) getRelQs(md interface{}, mi *modelInfo, fi *fieldInfo) *querySet {
// table name can be string or struct.
// e.g. QueryTable("user"), QueryTable(&user{}) or QueryTable((*User)(nil)),
func
(
o
*
orm
)
QueryTable
(
ptrStructOrTableName
interface
{})
(
qs
QuerySeter
)
{
name
:=
""
var
name
string
if
table
,
ok
:=
ptrStructOrTableName
.
(
string
);
ok
{
name
=
snakeString
(
table
)
if
mi
,
ok
:=
modelCache
.
get
(
name
);
ok
{
...
...
orm/orm_raw.go
View file @
aa8f7bc1
...
...
@@ -671,7 +671,7 @@ func (o *rawSet) queryRowsTo(container interface{}, keyCol, valueCol string) (in
ind
*
reflect
.
Value
)
typ
:=
0
var
typ
int
switch
container
.
(
type
)
{
case
*
Params
:
typ
=
1
...
...
orm/orm_test.go
View file @
aa8f7bc1
...
...
@@ -1140,6 +1140,7 @@ func TestRelatedSel(t *testing.T) {
}
err
=
qs
.
Filter
(
"user_name"
,
"nobody"
)
.
RelatedSel
(
"profile"
)
.
One
(
&
user
)
throwFail
(
t
,
err
)
throwFail
(
t
,
AssertIs
(
num
,
1
))
throwFail
(
t
,
AssertIs
(
user
.
Profile
,
nil
))
...
...
@@ -1248,20 +1249,24 @@ func TestLoadRelated(t *testing.T) {
num
,
err
=
dORM
.
LoadRelated
(
&
user
,
"Posts"
,
true
)
throwFailNow
(
t
,
err
)
throwFailNow
(
t
,
AssertIs
(
num
,
2
))
throwFailNow
(
t
,
AssertIs
(
len
(
user
.
Posts
),
2
))
throwFailNow
(
t
,
AssertIs
(
user
.
Posts
[
0
]
.
User
.
UserName
,
"astaxie"
))
num
,
err
=
dORM
.
LoadRelated
(
&
user
,
"Posts"
,
true
,
1
)
throwFailNow
(
t
,
err
)
throwFailNow
(
t
,
AssertIs
(
num
,
1
))
throwFailNow
(
t
,
AssertIs
(
len
(
user
.
Posts
),
1
))
num
,
err
=
dORM
.
LoadRelated
(
&
user
,
"Posts"
,
true
,
0
,
0
,
"-Id"
)
throwFailNow
(
t
,
err
)
throwFailNow
(
t
,
AssertIs
(
num
,
2
))
throwFailNow
(
t
,
AssertIs
(
len
(
user
.
Posts
),
2
))
throwFailNow
(
t
,
AssertIs
(
user
.
Posts
[
0
]
.
Title
,
"Formatting"
))
num
,
err
=
dORM
.
LoadRelated
(
&
user
,
"Posts"
,
true
,
1
,
1
,
"Id"
)
throwFailNow
(
t
,
err
)
throwFailNow
(
t
,
AssertIs
(
num
,
1
))
throwFailNow
(
t
,
AssertIs
(
len
(
user
.
Posts
),
1
))
throwFailNow
(
t
,
AssertIs
(
user
.
Posts
[
0
]
.
Title
,
"Formatting"
))
...
...
@@ -1978,6 +1983,7 @@ func TestReadOrCreate(t *testing.T) {
created
,
pk
,
err
:=
dORM
.
ReadOrCreate
(
u
,
"UserName"
)
throwFail
(
t
,
err
)
throwFail
(
t
,
AssertIs
(
created
,
true
))
throwFail
(
t
,
AssertIs
(
u
.
ID
,
pk
))
throwFail
(
t
,
AssertIs
(
u
.
UserName
,
"Kyle"
))
throwFail
(
t
,
AssertIs
(
u
.
Email
,
"kylemcc@gmail.com"
))
throwFail
(
t
,
AssertIs
(
u
.
Password
,
"other_pass"
))
...
...
@@ -2134,6 +2140,7 @@ func TestUintPk(t *testing.T) {
created
,
pk
,
err
:=
dORM
.
ReadOrCreate
(
u
,
"ID"
)
throwFail
(
t
,
err
)
throwFail
(
t
,
AssertIs
(
pk
,
u
.
ID
))
throwFail
(
t
,
AssertIs
(
created
,
true
))
throwFail
(
t
,
AssertIs
(
u
.
Name
,
name
))
...
...
session/couchbase/sess_couchbase.go
View file @
aa8f7bc1
...
...
@@ -162,7 +162,9 @@ func (cp *Provider) SessionRead(sid string) (session.Store, error) {
)
err
=
cp
.
b
.
Get
(
sid
,
&
doc
)
if
doc
==
nil
{
if
err
!=
nil
{
return
nil
,
err
}
else
if
doc
==
nil
{
kv
=
make
(
map
[
interface
{}]
interface
{})
}
else
{
kv
,
err
=
session
.
DecodeGob
(
doc
)
...
...
session/sess_test.go
View file @
aa8f7bc1
...
...
@@ -74,8 +74,7 @@ func TestCookieEncodeDecode(t *testing.T) {
if
err
!=
nil
{
t
.
Fatal
(
"encodeCookie:"
,
err
)
}
dst
:=
make
(
map
[
interface
{}]
interface
{})
dst
,
err
=
decodeCookie
(
block
,
hashKey
,
securityName
,
str
,
3600
)
dst
,
err
:=
decodeCookie
(
block
,
hashKey
,
securityName
,
str
,
3600
)
if
err
!=
nil
{
t
.
Fatal
(
"decodeCookie"
,
err
)
}
...
...
template.go
View file @
aa8f7bc1
...
...
@@ -307,8 +307,9 @@ func _getTemplate(t0 *template.Template, root string, subMods [][]string, others
}
//second check define
for
_
,
otherFile
:=
range
others
{
var
data
[]
byte
fileAbsPath
:=
filepath
.
Join
(
root
,
otherFile
)
data
,
err
:
=
ioutil
.
ReadFile
(
fileAbsPath
)
data
,
err
=
ioutil
.
ReadFile
(
fileAbsPath
)
if
err
!=
nil
{
continue
}
...
...
templatefunc_test.go
View file @
aa8f7bc1
...
...
@@ -254,22 +254,22 @@ func TestParseFormTag(t *testing.T) {
objT
:=
reflect
.
TypeOf
(
&
user
{})
.
Elem
()
label
,
name
,
fType
,
id
,
class
,
ignored
,
required
:=
parseFormTag
(
objT
.
Field
(
0
))
label
,
name
,
fType
,
_
,
_
,
ignored
,
_
:=
parseFormTag
(
objT
.
Field
(
0
))
if
!
(
name
==
"name"
&&
label
==
"年龄:"
&&
fType
==
"text"
&&
!
ignored
)
{
t
.
Errorf
(
"Form Tag with name, label and type was not correctly parsed."
)
}
label
,
name
,
fType
,
id
,
class
,
ignored
,
required
=
parseFormTag
(
objT
.
Field
(
1
))
label
,
name
,
fType
,
_
,
_
,
ignored
,
_
=
parseFormTag
(
objT
.
Field
(
1
))
if
!
(
name
==
"NoName"
&&
label
==
"年龄:"
&&
fType
==
"hidden"
&&
!
ignored
)
{
t
.
Errorf
(
"Form Tag with label and type but without name was not correctly parsed."
)
}
label
,
name
,
fType
,
id
,
class
,
ignored
,
required
=
parseFormTag
(
objT
.
Field
(
2
))
label
,
name
,
fType
,
_
,
_
,
ignored
,
_
=
parseFormTag
(
objT
.
Field
(
2
))
if
!
(
name
==
"OnlyLabel"
&&
label
==
"年龄:"
&&
fType
==
"text"
&&
!
ignored
)
{
t
.
Errorf
(
"Form Tag containing only label was not correctly parsed."
)
}
label
,
name
,
fType
,
id
,
class
,
ignored
,
_
=
parseFormTag
(
objT
.
Field
(
3
))
label
,
name
,
fType
,
id
,
class
,
ignored
,
_
:
=
parseFormTag
(
objT
.
Field
(
3
))
if
!
(
name
==
"name"
&&
label
==
"OnlyName: "
&&
fType
==
"text"
&&
!
ignored
&&
id
==
"name"
&&
class
==
"form-name"
)
{
t
.
Errorf
(
"Form Tag containing only name was not correctly parsed."
)
...
...
@@ -280,7 +280,7 @@ func TestParseFormTag(t *testing.T) {
t
.
Errorf
(
"Form Tag that should be ignored was not correctly parsed."
)
}
_
,
name
,
_
,
_
,
_
,
_
,
required
=
parseFormTag
(
objT
.
Field
(
5
))
_
,
name
,
_
,
_
,
_
,
_
,
required
:
=
parseFormTag
(
objT
.
Field
(
5
))
if
!
(
name
==
"name"
&&
required
)
{
t
.
Errorf
(
"Form Tag containing only name and required was not correctly parsed."
)
}
...
...
utils/file.go
View file @
aa8f7bc1
...
...
@@ -72,7 +72,7 @@ func GrepFile(patten string, filename string) (lines []string, err error) {
lines
=
make
([]
string
,
0
)
reader
:=
bufio
.
NewReader
(
fd
)
prefix
:=
""
isLongLine
:=
false
var
isLongLine
bool
for
{
byteLine
,
isPrefix
,
er
:=
reader
.
ReadLine
()
if
er
!=
nil
&&
er
!=
io
.
EOF
{
...
...
validation/util_test.go
View file @
aa8f7bc1
...
...
@@ -42,7 +42,7 @@ func TestGetValidFuncs(t *testing.T) {
}
f
,
_
=
tf
.
FieldByName
(
"Tag"
)
if
vfs
,
err
=
getValidFuncs
(
f
);
err
.
Error
()
!=
"doesn't exsits Maxx valid function"
{
if
_
,
err
=
getValidFuncs
(
f
);
err
.
Error
()
!=
"doesn't exsits Maxx valid function"
{
t
.
Fatal
(
err
)
}
...
...
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