1
0
mirror of https://github.com/golang/go synced 2024-11-14 07:20:22 -07:00
go/src/reflect
Pravendra Singh 538b3a5f37 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/45590
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-06-13 21:51:17 +00:00
..
all_test.go reflect: prevent structs with invalid field name 2017-06-13 21:51:17 +00:00
asm_386.s all: make copyright headers consistent with one space after period 2016-03-01 23:34:33 +00:00
asm_amd64.s all: make copyright headers consistent with one space after period 2016-03-01 23:34:33 +00:00
asm_amd64p32.s all: make copyright headers consistent with one space after period 2016-03-01 23:34:33 +00:00
asm_arm64.s all: make copyright headers consistent with one space after period 2016-03-01 23:34:33 +00:00
asm_arm.s all: make copyright headers consistent with one space after period 2016-03-01 23:34:33 +00:00
asm_mips64x.s all: make copyright headers consistent with one space after period 2016-03-01 23:34:33 +00:00
asm_mipsx.s reflect: add support for GOARCH=mips{,le} 2016-11-03 23:01:05 +00:00
asm_ppc64x.s all: make copyright headers consistent with one space after period 2016-03-01 23:34:33 +00:00
asm_s390x.s reflect: add s390x support 2016-04-06 04:23:06 +00:00
deepequal.go reflect: fix DeepEqual for some cyclic corner cases 2016-10-24 15:20:23 +00:00
example_test.go reflect: add example for StructOf 2016-12-06 20:18:12 +00:00
export_test.go reflect: unexported fields are tied to a package 2016-11-10 14:06:23 +00:00
makefunc.go runtime: clean up and improve reflect.methodValue comments 2016-12-19 21:02:53 +00:00
set_test.go reflect: check pkgPath for unexported methods in Implements 2017-06-08 00:54:14 +00:00
swapper.go reflect: add Swapper func 2016-09-30 20:26:54 +00:00
tostring_test.go
type.go reflect: prevent structs with invalid field name 2017-06-13 21:51:17 +00:00
value.go reflect: remove dead v.typ assignment 2017-05-11 08:07:21 +00:00