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 returns types with unpopulated StructField.PkgPath #36191

Closed
dsnet opened this issue Dec 17, 2019 · 3 comments
Closed

reflect: StructOf returns types with unpopulated StructField.PkgPath #36191

dsnet opened this issue Dec 17, 2019 · 3 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@dsnet
Copy link
Member

dsnet commented Dec 17, 2019

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 dsnet added this to the Go1.14 milestone Dec 17, 2019
@dmitshur
Copy link
Contributor

@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.

@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Dec 18, 2019
@dsnet
Copy link
Member Author

dsnet commented Dec 18, 2019

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

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/212001 mentions this issue: reflect: record PkgPath of StructOf arguments

@golang golang locked and limited conversation to collaborators Dec 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants