trySetUsingParser tries to set a custom type value based on the presence of the "parser" tag on the field. If the parser tag does not exist or does not match any of the supported parsers, gin will skip over this.
(val string, value reflect.Value, parser string)
| 199 | // trySetUsingParser tries to set a custom type value based on the presence of the "parser" tag on the field. |
| 200 | // If the parser tag does not exist or does not match any of the supported parsers, gin will skip over this. |
| 201 | func trySetUsingParser(val string, value reflect.Value, parser string) (isSet bool, err error) { |
| 202 | switch parser { |
| 203 | case "encoding.TextUnmarshaler": |
| 204 | v, ok := value.Addr().Interface().(encoding.TextUnmarshaler) |
| 205 | if !ok { |
| 206 | return false, nil |
| 207 | } |
| 208 | return true, v.UnmarshalText([]byte(val)) |
| 209 | } |
| 210 | return false, nil |
| 211 | } |
| 212 | |
| 213 | func trySplit(vs []string, field reflect.StructField) (newVs []string, err error) { |
| 214 | cfTag := field.Tag.Get("collection_format") |
no test coverage detected