refactor(binding): use strings.Cut to replace strings.Index (#3522)

This commit is contained in:
lgbgbl 2024-05-08 06:28:15 +08:00 committed by GitHub
parent e60113dc95
commit 8dd088927a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 5 deletions

View File

@ -397,11 +397,8 @@ func setTimeDuration(val string, value reflect.Value) error {
}
func head(str, sep string) (head string, tail string) {
idx := strings.Index(str, sep)
if idx < 0 {
return str, ""
}
return str[:idx], str[idx+len(sep):]
head, tail, _ = strings.Cut(str, sep)
return head, tail
}
func setFormMap(ptr any, form map[string][]string) error {