Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reflect: StructOf should support non-ASCII field names or types #15064

Closed
sbinet opened this issue Apr 1, 2016 · 2 comments
Closed

reflect: StructOf should support non-ASCII field names or types #15064

sbinet opened this issue Apr 1, 2016 · 2 comments
Milestone

Comments

@sbinet
Copy link
Member

sbinet commented Apr 1, 2016

see https://golang.org/cl/9251 for more details but in a nutshell:

reflect.StructOf needs to know whether a field is exported or not.
To do that, the canonical way is:

// isExported reports whether name is an exported Go symbol
// (that is, whether it begins with an upper-case letter).
//
func isExported(name string) bool {
    ch, _ := utf8.DecodeRuneInString(name)
    return unicode.IsUpper(ch)
}

But reflect should not embed the whole lot of UTF-8 symbol tables.
We need to fix that before go-1.7

gopherbot pushed a commit that referenced this issue Apr 1, 2016
This change exposes a facility to create new struct types from a slice of
reflect.StructFields.

- reflect: first stab at implementing StructOf
- reflect: tests for StructOf

StructOf creates new struct types in the form of structTypeWithMethods
to accomodate the GC (especially the uncommonType.methods slice field.)

Creating struct types with embedded interfaces with unexported methods
is not supported yet and will panic.
Creating struct types with non-ASCII field names or types is not yet
supported (see #15064.)

Binaries' sizes for linux_amd64:

old=tip (0104a31)

            old bytes     new bytes     delta
bin/go      9911336       9915456       +0.04%
reflect     781704        830048        +6.18%

Updates #5748.
Updates #15064.

Change-Id: I3b8fd4fadd6ce3b1b922e284f0ae72a3a8e3ce44
Reviewed-on: https://go-review.googlesource.com/9251
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
@bradfitz bradfitz added this to the Go1.7 milestone Apr 1, 2016
@gopherbot
Copy link
Contributor

CL https://golang.org/cl/21777 mentions this issue.

@gopherbot
Copy link
Contributor

CL https://golang.org/cl/23170 mentions this issue.

gopherbot pushed a commit that referenced this issue May 17, 2016
The initial implementation of reflect.StructOf in
https://golang.org/cl/9251 had a limitation that field names had to be
ASCII, which was later lifted by https://golang.org/cl/21777.  Remove
the out-of-date documentation disallowing UTF-8 field names.

Updates: #5748
Updates: #15064

Change-Id: I2c5bfea46bfd682449c6e847fc972a1a131f51b7
Reviewed-on: https://go-review.googlesource.com/23170
Reviewed-by: David Crawshaw <crawshaw@golang.org>
@golang golang locked and limited conversation to collaborators May 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants