mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-15 04:57:07 +08:00
feat(form): add array collection format in form binding
This commit is contained in:
parent
78822bf198
commit
b8cfe5ae4d
@ -202,7 +202,11 @@ func trySplit(vs []string, field reflect.StructField) (newVs []string, err error
|
|||||||
return vs, fmt.Errorf("%s is not supported in the collection_format. (csv, ssv, pipes)", cfTag)
|
return vs, fmt.Errorf("%s is not supported in the collection_format. (csv, ssv, pipes)", cfTag)
|
||||||
}
|
}
|
||||||
|
|
||||||
newVs = make([]string, 0)
|
totalLength := 0
|
||||||
|
for _, v := range vs {
|
||||||
|
totalLength += strings.Count(v, sep) + 1
|
||||||
|
}
|
||||||
|
newVs = make([]string, 0, totalLength)
|
||||||
for _, v := range vs {
|
for _, v := range vs {
|
||||||
newVs = append(newVs, strings.Split(v, sep)...)
|
newVs = append(newVs, strings.Split(v, sep)...)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user