Skip to content

Commit 67d7e69

Browse files
author
Fabrice Vaillant
committed
Favor strings.Cut to strings.SplitN
It is more efficient since it does not allocate an array and just return s if nothing found For the same reason we don't need to use strings.Cut at all if empty
1 parent 8508981 commit 67d7e69

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

mapstructure.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1358,8 +1358,8 @@ func (d *Decoder) decodeStructFromMap(name string, dataVal, val reflect.Value) e
13581358
fieldName := field.Name
13591359

13601360
tagValue := field.Tag.Get(d.config.TagName)
1361-
tagValue = strings.SplitN(tagValue, ",", 2)[0]
13621361
if tagValue != "" {
1362+
tagValue, _, _ = strings.Cut(tagValue, ",")
13631363
fieldName = tagValue
13641364
}
13651365

0 commit comments

Comments
 (0)