MCPcopy Index your code
hub / github.com/google/go-querystring / Values

Function Values

query/encode.go:125–146  ·  view source on GitHub ↗

Values returns the url.Values encoding of v. Values expects to be passed a struct, and traverses it recursively using the following encoding rules. 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 "omitempt

(v interface{})

Source from the content-addressed store, hash-verified

123// Multiple fields that encode to the same URL parameter name will be included
124// as multiple URL values of the same name.
125func Values(v interface{}) (url.Values, error) {
126 values := make(url.Values)
127
128 if v == nil {
129 return values, nil
130 }
131
132 val := reflect.ValueOf(v)
133 for val.Kind() == reflect.Ptr {
134 if val.IsNil() {
135 return values, nil
136 }
137 val = val.Elem()
138 }
139
140 if val.Kind() != reflect.Struct {
141 return nil, fmt.Errorf("query: Values() expects struct input. Got %v", val.Kind())
142 }
143
144 err := reflectValue(values, val, "")
145 return values, err
146}
147
148// reflectValue populates the values parameter from the struct fields in val.
149// Embedded structs are followed recursively (using the rules defined in the

Callers 3

testValueFunction · 0.85
TestValues_InvalidInputFunction · 0.85

Calls 1

reflectValueFunction · 0.85

Tested by 3

testValueFunction · 0.68
TestValues_InvalidInputFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…