You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
add a flag like "isMatched" when matched with nameIndex set the flag "true"
like this:
typestructFieldsstruct {
list []fieldnameIndexmap[string]int
}
// A field represents a single field found in a struct.typefieldstruct {
...isMatchedbool// add a flag when nameIndex matched
}
ifi, ok:=fields.nameIndex[string(key)]; ok {
// Found an exact name match.f=&fields.list[i]
+f.isMatched=true
} else {
// Fall back to the expensive case-insensitive// linear search.fori:=rangefields.list {
ff:=&fields.list[i]
+if!ff.isMatched&&ff.equalFold(ff.nameBytes, key) {
f=ffbreak
}
}
}
The text was updated successfully, but these errors were encountered:
in this case the id field value is 5 , but the key "id" is match in better.
add a flag like "isMatched" when matched with nameIndex set the flag "true"
like this:
https://github.com/golang/go/blob/master/src/encoding/json/decode.go#L702
The text was updated successfully, but these errors were encountered: