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
5c859466
Commit
5c859466
authored
Aug 11, 2013
by
miraclesu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ignore struct field if form tag value is '-'
parent
449fbe82
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
2 deletions
+6
-2
utils.go
utils.go
+2
-0
utils_test.go
utils_test.go
+4
-2
No files found.
utils.go
View file @
5c859466
...
...
@@ -195,6 +195,8 @@ func ParseForm(form url.Values, obj interface{}) error {
var
tag
string
if
len
(
tags
)
==
0
||
len
(
tags
[
0
])
==
0
{
tag
=
fieldT
.
Name
}
else
if
tags
[
0
]
==
"-"
{
continue
}
else
{
tag
=
tags
[
0
]
}
...
...
utils_test.go
View file @
5c859466
...
...
@@ -104,8 +104,8 @@ func TestInSlice(t *testing.T) {
func
TestParseForm
(
t
*
testing
.
T
)
{
type
user
struct
{
Id
int
tag
string
`form:
tag
`
Id
int
`form:"-"`
tag
string
`form:
"tag"
`
Name
interface
{}
`form:"username"`
Age
int
`form:"age,text"`
Email
string
...
...
@@ -114,6 +114,8 @@ func TestParseForm(t *testing.T) {
u
:=
user
{}
form
:=
url
.
Values
{
"Id"
:
[]
string
{
"1"
},
"-"
:
[]
string
{
"1"
},
"tag"
:
[]
string
{
"no"
},
"username"
:
[]
string
{
"test"
},
"age"
:
[]
string
{
"40"
},
...
...
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