MCPcopy
hub / github.com/gin-gonic/gin / trySetCustom

Function trySetCustom

binding/form_mapping.go:191–197  ·  binding/form_mapping.go::trySetCustom

trySetCustom tries to set a custom type value If the value implements the BindUnmarshaler interface, it will be used to set the value, we will return `true` to skip the default value setting.

(val string, value reflect.Value)

Source from the content-addressed store, hash-verified

189// If the value implements the BindUnmarshaler interface, it will be used to set the value, we will return `true`
190// to skip the default value setting.
191func trySetCustom(val string, value reflect.Value) (isSet bool, err error) {
192 switch v := value.Addr().Interface().(type) {
193 case BindUnmarshaler:
194 return true, v.UnmarshalParam(val)
195 }
196 return false, nil
197}
198
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.

Callers 2

setByFormFunction · 0.85
setWithProperTypeFunction · 0.85

Calls 1

UnmarshalParamMethod · 0.65

Tested by

no test coverage detected