Update all dependencies
Update all deps. Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
parent
3640235eeb
commit
47537fb8b6
757 changed files with 87315 additions and 14280 deletions
73
vendor/github.com/google/go-querystring/query/encode.go
generated
vendored
73
vendor/github.com/google/go-querystring/query/encode.go
generated
vendored
|
|
@ -6,22 +6,21 @@
|
|||
//
|
||||
// As a simple example:
|
||||
//
|
||||
// type Options struct {
|
||||
// Query string `url:"q"`
|
||||
// ShowAll bool `url:"all"`
|
||||
// Page int `url:"page"`
|
||||
// }
|
||||
// type Options struct {
|
||||
// Query string `url:"q"`
|
||||
// ShowAll bool `url:"all"`
|
||||
// Page int `url:"page"`
|
||||
// }
|
||||
//
|
||||
// opt := Options{ "foo", true, 2 }
|
||||
// v, _ := query.Values(opt)
|
||||
// fmt.Print(v.Encode()) // will output: "q=foo&all=true&page=2"
|
||||
// opt := Options{ "foo", true, 2 }
|
||||
// v, _ := query.Values(opt)
|
||||
// fmt.Print(v.Encode()) // will output: "q=foo&all=true&page=2"
|
||||
//
|
||||
// The exact mapping between Go values and url.Values is described in the
|
||||
// documentation for the Values() function.
|
||||
package query
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"reflect"
|
||||
|
|
@ -47,8 +46,8 @@ type Encoder interface {
|
|||
//
|
||||
// Each exported struct field is encoded as a URL parameter unless
|
||||
//
|
||||
// - the field's tag is "-", or
|
||||
// - the field is empty and its tag specifies the "omitempty" option
|
||||
// - the field's tag is "-", or
|
||||
// - the field is empty and its tag specifies the "omitempty" option
|
||||
//
|
||||
// The empty values are false, 0, any nil pointer or interface value, any array
|
||||
// slice, map, or string of length zero, and any type (such as time.Time) that
|
||||
|
|
@ -59,19 +58,19 @@ type Encoder interface {
|
|||
// field's tag value is the key name, followed by an optional comma and
|
||||
// options. For example:
|
||||
//
|
||||
// // Field is ignored by this package.
|
||||
// Field int `url:"-"`
|
||||
// // Field is ignored by this package.
|
||||
// Field int `url:"-"`
|
||||
//
|
||||
// // Field appears as URL parameter "myName".
|
||||
// Field int `url:"myName"`
|
||||
// // Field appears as URL parameter "myName".
|
||||
// Field int `url:"myName"`
|
||||
//
|
||||
// // Field appears as URL parameter "myName" and the field is omitted if
|
||||
// // its value is empty
|
||||
// Field int `url:"myName,omitempty"`
|
||||
// // Field appears as URL parameter "myName" and the field is omitted if
|
||||
// // its value is empty
|
||||
// Field int `url:"myName,omitempty"`
|
||||
//
|
||||
// // Field appears as URL parameter "Field" (the default), but the field
|
||||
// // is skipped if empty. Note the leading comma.
|
||||
// Field int `url:",omitempty"`
|
||||
// // Field appears as URL parameter "Field" (the default), but the field
|
||||
// // is skipped if empty. Note the leading comma.
|
||||
// Field int `url:",omitempty"`
|
||||
//
|
||||
// For encoding individual field values, the following type-dependent rules
|
||||
// apply:
|
||||
|
|
@ -88,8 +87,8 @@ type Encoder interface {
|
|||
// "url" tag) will use the value of the "layout" tag as a layout passed to
|
||||
// time.Format. For example:
|
||||
//
|
||||
// // Encode a time.Time as YYYY-MM-DD
|
||||
// Field time.Time `layout:"2006-01-02"`
|
||||
// // Encode a time.Time as YYYY-MM-DD
|
||||
// Field time.Time `layout:"2006-01-02"`
|
||||
//
|
||||
// Slice and Array values default to encoding as multiple URL values of the
|
||||
// same name. Including the "comma" option signals that the field should be
|
||||
|
|
@ -103,9 +102,9 @@ type Encoder interface {
|
|||
// from the "url" tag) will use the value of the "del" tag as the delimiter.
|
||||
// For example:
|
||||
//
|
||||
// // Encode a slice of bools as ints ("1" for true, "0" for false),
|
||||
// // separated by exclamation points "!".
|
||||
// Field []bool `url:",int" del:"!"`
|
||||
// // Encode a slice of bools as ints ("1" for true, "0" for false),
|
||||
// // separated by exclamation points "!".
|
||||
// Field []bool `url:",int" del:"!"`
|
||||
//
|
||||
// Anonymous struct fields are usually encoded as if their inner exported
|
||||
// fields were fields in the outer struct, subject to the standard Go
|
||||
|
|
@ -114,10 +113,10 @@ type Encoder interface {
|
|||
//
|
||||
// Non-nil pointer values are encoded as the value pointed to.
|
||||
//
|
||||
// Nested structs are encoded including parent fields in value names for
|
||||
// scoping. e.g:
|
||||
// Nested structs have their fields processed recursively and are encoded
|
||||
// including parent fields in value names for scoping. For example,
|
||||
//
|
||||
// "user[name]=acme&user[addr][postcode]=1234&user[addr][city]=SFO"
|
||||
// "user[name]=acme&user[addr][postcode]=1234&user[addr][city]=SFO"
|
||||
//
|
||||
// All other values are encoded using their default string representation.
|
||||
//
|
||||
|
|
@ -125,6 +124,11 @@ type Encoder interface {
|
|||
// as multiple URL values of the same name.
|
||||
func Values(v interface{}) (url.Values, error) {
|
||||
values := make(url.Values)
|
||||
|
||||
if v == nil {
|
||||
return values, nil
|
||||
}
|
||||
|
||||
val := reflect.ValueOf(v)
|
||||
for val.Kind() == reflect.Ptr {
|
||||
if val.IsNil() {
|
||||
|
|
@ -133,10 +137,6 @@ func Values(v interface{}) (url.Values, error) {
|
|||
val = val.Elem()
|
||||
}
|
||||
|
||||
if v == nil {
|
||||
return values, nil
|
||||
}
|
||||
|
||||
if val.Kind() != reflect.Struct {
|
||||
return nil, fmt.Errorf("query: Values() expects struct input. Got %v", val.Kind())
|
||||
}
|
||||
|
|
@ -209,6 +209,11 @@ func reflectValue(values url.Values, val reflect.Value, scope string) error {
|
|||
}
|
||||
|
||||
if sv.Kind() == reflect.Slice || sv.Kind() == reflect.Array {
|
||||
if sv.Len() == 0 {
|
||||
// skip if slice or array is empty
|
||||
continue
|
||||
}
|
||||
|
||||
var del string
|
||||
if opts.Contains("comma") {
|
||||
del = ","
|
||||
|
|
@ -223,7 +228,7 @@ func reflectValue(values url.Values, val reflect.Value, scope string) error {
|
|||
}
|
||||
|
||||
if del != "" {
|
||||
s := new(bytes.Buffer)
|
||||
s := new(strings.Builder)
|
||||
first := true
|
||||
for i := 0; i < sv.Len(); i++ {
|
||||
if first {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue