mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 06:54:01 +00:00
Dont output nil; test nil & omitempty
This commit is contained in:
parent
edfaa480cf
commit
6c32e071f4
@ -74,7 +74,13 @@ func addParam(values url.Values, tag string, omitempty bool, value reflect.Value
|
||||
if omitempty && zeroValue(value) {
|
||||
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) {
|
||||
|
@ -151,6 +151,12 @@ func TestConvert(t *testing.T) {
|
||||
},
|
||||
expected: url.Values{"ptr": {"<nil>"}, "bptr": {"true"}},
|
||||
},
|
||||
{
|
||||
input: &baz{
|
||||
Ptr: intp(5),
|
||||
},
|
||||
expected: url.Values{"ptr": {"5"}},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
Loading…
Reference in New Issue
Block a user