Showing 1 of 3 files from the diff.
Other files ignored by Codecov

@@ -29,6 +29,21 @@
Loading
29 29
var emptyField = reflect.StructField{}
30 30
31 31
func mapFormByTag(ptr interface{}, form map[string][]string, tag string) error {
32 +
	// Check if ptr is a map
33 +
	ptrVal := reflect.ValueOf(ptr)
34 +
	var pointed interface{}
35 +
	if ptrVal.Kind() == reflect.Ptr {
36 +
		ptrVal = ptrVal.Elem()
37 +
		pointed = ptrVal.Interface()
38 +
	}
39 +
	if ptrVal.Kind() == reflect.Map &&
40 +
		ptrVal.Type().Key().Kind() == reflect.String {
41 +
		if pointed != nil {
42 +
			ptr = pointed
43 +
		}
44 +
		return setFormMap(ptr, form)
45 +
	}
46 +
32 47
	return mappingByPtr(ptr, formSource(form), tag)
33 48
}
34 49
@@ -349,3 +364,29 @@
Loading
349 364
	}
350 365
	return str[:idx], str[idx+len(sep):]
351 366
}
367 +
368 +
func setFormMap(ptr interface{}, form map[string][]string) error {
369 +
	el := reflect.TypeOf(ptr).Elem()
370 +
371 +
	if el.Kind() == reflect.Slice {
372 +
		ptrMap, ok := ptr.(map[string][]string)
373 +
		if !ok {
374 +
			return errors.New("cannot convert to map slices of strings")
375 +
		}
376 +
		for k, v := range form {
377 +
			ptrMap[k] = v
378 +
		}
379 +
380 +
		return nil
381 +
	}
382 +
383 +
	ptrMap, ok := ptr.(map[string]string)
384 +
	if !ok {
385 +
		return errors.New("cannot convert to map of strings")
386 +
	}
387 +
	for k, v := range form {
388 +
		ptrMap[k] = v[len(v)-1] // pick last
389 +
	}
390 +
391 +
	return nil
392 +
}
Files Coverage
binding 100.00%
render 92.96%
auth.go 100.00%
context.go 97.51%
debug.go 92.50%
deprecated.go 100.00%
errors.go 100.00%
fs.go 100.00%
gin.go 99.01%
logger.go 100.00%
mode.go 100.00%
path.go 100.00%
recovery.go 97.18%
response_writer.go 93.33%
routergroup.go 100.00%
test_helpers.go 100.00%
tree.go 100.00%
utils.go 96.83%
Project Totals (41 files) 98.48%
4711.2
1.13.x=.13.x
TRAVIS_OS_NAME=linux
4711.4
1.14.x=.14.x
TRAVIS_OS_NAME=linux
4711.3
1.13.x=.13.x
TRAVIS_OS_NAME=linux
4711.1
TRAVIS_OS_NAME=linux
1.12.x=.12.x
4710.5
1.14.x=.14.x
TRAVIS_OS_NAME=linux
4710.6
TRAVIS_OS_NAME=linux
1.15.x=.15.x
4710.7
TRAVIS_OS_NAME=linux
1.15.x=.15.x
4710.8
TRAVIS_OS_NAME=linux
master=
4711.7
TRAVIS_OS_NAME=linux
1.15.x=.15.x
4711.6
TRAVIS_OS_NAME=linux
1.15.x=.15.x
4707.2
1.13.x=.13.x
TRAVIS_OS_NAME=linux
4707.5
1.14.x=.14.x
TRAVIS_OS_NAME=linux
4709.3
1.13.x=.13.x
TRAVIS_OS_NAME=linux
4716.5
1.14.x=.14.x
TRAVIS_OS_NAME=linux
4716.1
TRAVIS_OS_NAME=linux
1.12.x=.12.x
4716.4
1.14.x=.14.x
TRAVIS_OS_NAME=linux
4715.8
TRAVIS_OS_NAME=linux
master=
4716.2
1.13.x=.13.x
TRAVIS_OS_NAME=linux
4716.3
1.13.x=.13.x
TRAVIS_OS_NAME=linux
4715.5
1.14.x=.14.x
TRAVIS_OS_NAME=linux