diff --git a/query/encode.go b/query/encode.go index ffb2097..ffe56bc 100644 --- a/query/encode.go +++ b/query/encode.go @@ -282,7 +282,7 @@ func reflectValue(values url.Values, val reflect.Value, scope string) error { // valueString returns the string representation of a value. func valueString(v reflect.Value, opts tagOptions, sf reflect.StructField) string { - for v.Kind() == reflect.Ptr { + for v.Kind() == reflect.Ptr || (v.Kind() == reflect.Interface && !v.IsNil()) { if v.IsNil() { return "" } diff --git a/query/encode_test.go b/query/encode_test.go index 241e4f1..82b05bd 100644 --- a/query/encode_test.go +++ b/query/encode_test.go @@ -265,6 +265,18 @@ func TestValues_Slices(t *testing.T) { }{[]bool{true, false}}, url.Values{"V": {"1 0"}}, }, + { + struct { + V []interface{} `url:",space,int"` + }{[]interface{}{true, false}}, + url.Values{"V": {"1 0"}}, + }, + { + struct { + V []interface{} `layout:"2006-01-02"` + }{[]interface{}{time.Date(2026, 10, 18, 0, 0, 0, 0, time.UTC)}}, + url.Values{"V": {"2026-10-18"}}, + }, } for _, tt := range tests {