diff --git a/binding/form_mapping.go b/binding/form_mapping.go index 93d3ca2ab5..4a35866da2 100644 --- a/binding/form_mapping.go +++ b/binding/form_mapping.go @@ -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) } - 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 { newVs = append(newVs, strings.Split(v, sep)...) }