Skip to content

Commit 8dd0889

Browse files
authored
refactor(binding): use strings.Cut to replace strings.Index (#3522)
1 parent e60113d commit 8dd0889

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

binding/form_mapping.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -397,11 +397,8 @@ func setTimeDuration(val string, value reflect.Value) error {
397397
}
398398

399399
func head(str, sep string) (head string, tail string) {
400-
idx := strings.Index(str, sep)
401-
if idx < 0 {
402-
return str, ""
403-
}
404-
return str[:idx], str[idx+len(sep):]
400+
head, tail, _ = strings.Cut(str, sep)
401+
return head, tail
405402
}
406403

407404
func setFormMap(ptr any, form map[string][]string) error {

0 commit comments

Comments
 (0)