mirror of https://github.com/gin-gonic/gin.git
refactor(binding): use strings.Cut to replace strings.Index (#3522)
This commit is contained in:
parent
e60113dc95
commit
8dd088927a
|
@ -397,11 +397,8 @@ func setTimeDuration(val string, value reflect.Value) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func head(str, sep string) (head string, tail string) {
|
func head(str, sep string) (head string, tail string) {
|
||||||
idx := strings.Index(str, sep)
|
head, tail, _ = strings.Cut(str, sep)
|
||||||
if idx < 0 {
|
return head, tail
|
||||||
return str, ""
|
|
||||||
}
|
|
||||||
return str[:idx], str[idx+len(sep):]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func setFormMap(ptr any, form map[string][]string) error {
|
func setFormMap(ptr any, form map[string][]string) error {
|
||||||
|
|
Loading…
Reference in New Issue