From 67f2a34819285b4712f46b3de66384c49cf01ef7 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sun, 17 Jul 2016 03:43:32 +0200 Subject: Unify Array and Slice --- query/query.go | 6 +----- query/query_test.go | 4 +++- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/query/query.go b/query/query.go index 2e4ccc9..046c1de 100644 --- a/query/query.go +++ b/query/query.go @@ -59,11 +59,7 @@ func marshalQuery(v reflect.Value) (string, error) { q.Add(name, strconv.Itoa(int(f.Int()))) case reflect.String: q.Add(name, f.String()) - case reflect.Slice: - if f.Type().Elem().Kind() == reflect.Uint8 { - q.Add(name, string(f.Bytes())) - } - case reflect.Array: + case reflect.Slice, reflect.Array: if f.Type().Elem().Kind() == reflect.Uint8 { tmp := make([]byte, f.Len()) for i := 0; i < f.Len(); i++ { diff --git a/query/query_test.go b/query/query_test.go index 84d5ab1..5aaf61a 100644 --- a/query/query_test.go +++ b/query/query_test.go @@ -8,16 +8,18 @@ func TestMarshal(t *testing.T) { B int C string `query:",optional"` D [3]byte + E []byte }{ A: "test", B: 100, D: [3]byte{1, 2, 3}, + E: []byte{'A', 'B'}, } v, err := Marshal(q) if err != nil { t.Error(err) } - if v != "?b=100&d=%01%02%03&x=test" { + if v != "?b=100&d=%01%02%03&e=AB&x=test" { t.Error("wrong result", v) } -- cgit v1.2.3