reflect: StructOf returns types with unpopulated StructField.PkgPath
Closed this issue · 3 comments
At tip, the following:
t := reflect.StructOf([]reflect.StructField{{
Name: "height",
PkgPath: "path/to/pkg",
Type: reflect.TypeOf(float64(0)),
}})
fmt.Println(t.Field(0).PkgPath)
This currently prints nothing. I expect it to print path/to/pkg
otherwise logic to detect unexported fields doesn't work properly.
@dsnet Do you know if this is new to 1.14, or did it exist in older versions too? If it's new to Go 1.14, then the current Go 1.14 milestone makes sense. Otherwise we should milestone this as backlog or for 1.15.
/cc @rsc @ianlancetaylor per owners and /cc @griesemer since this may be related to the Go specification.
The ability for StructOf
to handle unexported fields was added in https://go-review.googlesource.com/c/go/+/85661
This has not seen a stable release yet.
\cc @crawshaw
Change https://golang.org/cl/212001 mentions this issue: reflect: record PkgPath of StructOf arguments