From e04015f552b5e454e67038fa7808efcc4b941888 Mon Sep 17 00:00:00 2001 From: lgbgbl Date: Sat, 4 Mar 2023 21:18:23 +0800 Subject: [PATCH] refactor: use strings.Cut to replace strings.Index --- binding/form_mapping.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/binding/form_mapping.go b/binding/form_mapping.go index 77a1bde6..f928c4ce 100644 --- a/binding/form_mapping.go +++ b/binding/form_mapping.go @@ -377,11 +377,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 {