From 8dd088927ab50b3b37be1f7ba14931c8eddafe07 Mon Sep 17 00:00:00 2001 From: lgbgbl <65756378+lgbgbl@users.noreply.github.com> Date: Wed, 8 May 2024 06:28:15 +0800 Subject: [PATCH] refactor(binding): use strings.Cut to replace strings.Index (#3522) --- 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 db235e56..108606fa 100644 --- a/binding/form_mapping.go +++ b/binding/form_mapping.go @@ -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 {