reflect: prevent structs with invalid field name
According to the language spec, a struct field name should be an identifier. identifier = letter { letter | unicode_digit } . letter = unicode_letter | "_" . Implements a function 'isValidFieldName(fieldName string) bool'. To check if the field name is a valid identifier or not. It will panic if the field name is invalid. It uses the non-exported function implementation 'isLetter' from the package 'scanner', used to parse an identifier. Fixes #20600. Change-Id: I1db7db1ad88cab5dbea6565be15cc7461cc56c44 Reviewed-on: https://go-review.googlesource.com/45590Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Showing
Please
register
or
sign in
to comment