(ptr any, form map[string][]string)
| 526 | } |
| 527 | |
| 528 | func setFormMap(ptr any, form map[string][]string) error { |
| 529 | el := reflect.TypeOf(ptr).Elem() |
| 530 | |
| 531 | if el.Kind() == reflect.Slice { |
| 532 | ptrMap, ok := ptr.(map[string][]string) |
| 533 | if !ok { |
| 534 | return ErrConvertMapStringSlice |
| 535 | } |
| 536 | maps.Copy(ptrMap, form) |
| 537 | |
| 538 | return nil |
| 539 | } |
| 540 | |
| 541 | ptrMap, ok := ptr.(map[string]string) |
| 542 | if !ok { |
| 543 | return ErrConvertToMapString |
| 544 | } |
| 545 | for k, v := range form { |
| 546 | ptrMap[k] = v[len(v)-1] // pick last |
| 547 | } |
| 548 | |
| 549 | return nil |
| 550 | } |