Skip to content

Commit e8fedec

Browse files
committed
handle struct pointers passed to Values()
1 parent 0d72f00 commit e8fedec

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

query/encode.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,13 @@ func Values(v interface{}) (url.Values, error) {
8282
values := &url.Values{}
8383

8484
val := reflect.ValueOf(v)
85+
if val.Kind() == reflect.Ptr && val.IsNil() {
86+
return *values, nil
87+
}
88+
89+
val = reflect.Indirect(val)
8590
if val.Kind() != reflect.Struct {
86-
return nil, fmt.Errorf("query: Values() expects struct input")
91+
return nil, fmt.Errorf("query: Values() expects struct input. Got %v", val.Kind())
8792
}
8893

8994
reflectValue(values, val)

0 commit comments

Comments
 (0)