Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
6c32e071
Commit
6c32e071
authored
Sep 03, 2015
by
kargakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dont output nil; test nil & omitempty
parent
edfaa480
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletion
+13
-1
convert.go
pkg/conversion/queryparams/convert.go
+7
-1
convert_test.go
pkg/conversion/queryparams/convert_test.go
+6
-0
No files found.
pkg/conversion/queryparams/convert.go
View file @
6c32e071
...
@@ -74,7 +74,13 @@ func addParam(values url.Values, tag string, omitempty bool, value reflect.Value
...
@@ -74,7 +74,13 @@ func addParam(values url.Values, tag string, omitempty bool, value reflect.Value
if
omitempty
&&
zeroValue
(
value
)
{
if
omitempty
&&
zeroValue
(
value
)
{
return
return
}
}
values
.
Add
(
tag
,
fmt
.
Sprintf
(
"%v"
,
value
.
Interface
()))
val
:=
""
iValue
:=
fmt
.
Sprintf
(
"%v"
,
value
.
Interface
())
if
iValue
!=
"<nil>"
{
val
=
iValue
}
values
.
Add
(
tag
,
val
)
}
}
func
addListOfParams
(
values
url
.
Values
,
tag
string
,
omitempty
bool
,
list
reflect
.
Value
)
{
func
addListOfParams
(
values
url
.
Values
,
tag
string
,
omitempty
bool
,
list
reflect
.
Value
)
{
...
...
pkg/conversion/queryparams/convert_test.go
View file @
6c32e071
...
@@ -151,6 +151,12 @@ func TestConvert(t *testing.T) {
...
@@ -151,6 +151,12 @@ func TestConvert(t *testing.T) {
},
},
expected
:
url
.
Values
{
"ptr"
:
{
"<nil>"
},
"bptr"
:
{
"true"
}},
expected
:
url
.
Values
{
"ptr"
:
{
"<nil>"
},
"bptr"
:
{
"true"
}},
},
},
{
input
:
&
baz
{
Ptr
:
intp
(
5
),
},
expected
:
url
.
Values
{
"ptr"
:
{
"5"
}},
},
}
}
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
...
...
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