tryToSetValue() — gin Function Reference
Architecture documentation for the tryToSetValue() function in form_mapping.go from the gin codebase.
Entity Profile
Dependency Diagram
graph TD be2f0281_158f_19d5_81a3_7906a21c7875["tryToSetValue()"] ba99b96b_284d_628b_fac7_e9a63aea5c91["mapping()"] ba99b96b_284d_628b_fac7_e9a63aea5c91 -->|calls| be2f0281_158f_19d5_81a3_7906a21c7875 b22872c8_095e_a558_ccc8_c2d9d844ebd4["head()"] be2f0281_158f_19d5_81a3_7906a21c7875 -->|calls| b22872c8_095e_a558_ccc8_c2d9d844ebd4 28f27f7b_98e3_2633_4756_5d59d361ff59["TrySet()"] be2f0281_158f_19d5_81a3_7906a21c7875 -->|calls| 28f27f7b_98e3_2633_4756_5d59d361ff59 style be2f0281_158f_19d5_81a3_7906a21c7875 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
binding/form_mapping.go lines 145–180
func tryToSetValue(value reflect.Value, field reflect.StructField, setter setter, tag string) (bool, error) {
var tagValue string
var setOpt setOptions
tagValue = field.Tag.Get(tag)
tagValue, opts := head(tagValue, ",")
if tagValue == "" { // default value is FieldName
tagValue = field.Name
}
if tagValue == "" { // when field is "emptyField" variable
return false, nil
}
var opt string
for len(opts) > 0 {
opt, opts = head(opts, ",")
if k, v := head(opt, "="); k == "default" {
setOpt.isDefaultExists = true
setOpt.defaultValue = v
// convert semicolon-separated default values to csv-separated values for processing in setByForm
if field.Type.Kind() == reflect.Slice || field.Type.Kind() == reflect.Array {
cfTag := field.Tag.Get("collection_format")
if cfTag == "" || cfTag == "multi" || cfTag == "csv" {
setOpt.defaultValue = strings.ReplaceAll(v, ";", ",")
}
}
} else if k, v = head(opt, "="); k == "parser" {
setOpt.parser = v
}
}
return setter.TrySet(value, field, tagValue, setOpt)
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does tryToSetValue() do?
tryToSetValue() is a function in the gin codebase.
What does tryToSetValue() call?
tryToSetValue() calls 2 function(s): TrySet, head.
What calls tryToSetValue()?
tryToSetValue() is called by 1 function(s): mapping.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free