Skip to content

proposal: reflect: add Type.QualifiedString #42099

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

Closed
dsnet opened this issue Oct 20, 2020 · 4 comments
Closed

proposal: reflect: add Type.QualifiedString #42099

dsnet opened this issue Oct 20, 2020 · 4 comments

Comments

@dsnet
Copy link
Member

dsnet commented Oct 20, 2020

#22075 makes it such that NumMethod no longer counts unexported methods for interfaces (and by implication the inability to obtain information about unexported methods).

One use case this breaks is https://github.com/google/go-cmp/blob/566225a2554cf156c7af1006dc3a0940e1e02b09/cmp/internal/value/name.go#L133-L146, where the goal is to print fully-qualified type information about a Go type (i.e., reflect.Type.String is insufficiently detailed). With the NumMethod change, I can no longer print unnamed interfaces in a way where users can tell that they are different.

I propose we add a reflect.Type.QualifiedString method that ensures the following property:

t1.QualifiedString() == t2.QualifiedString() if and only if t1 == t2

I don't have any strong preferences for the content of the string other than it be a humanly readable representation of the type. If the output is Go syntax, perhaps the method can be called GoString.

\cc @mdempsky

@gopherbot gopherbot added this to the Proposal milestone Oct 20, 2020
@ianlancetaylor
Copy link
Member

See also #41896.

@dsnet dsnet changed the title proposal: reflect: add QualifiedString proposal: reflect: add Type.QualifiedString Oct 20, 2020
@rsc
Copy link
Contributor

rsc commented Oct 21, 2020

We are probably going to roll back that change - see #42123 - so it looks like we don't need this.

@rsc
Copy link
Contributor

rsc commented Oct 28, 2020

Since we rolled back that change, this seems like a likely decline.

@dsnet
Copy link
Member Author

dsnet commented Oct 28, 2020

I'm abandoning my proposal.

@dsnet dsnet closed this as completed Oct 28, 2020
@golang golang locked and limited conversation to collaborators Nov 4, 2021
@rsc rsc moved this to Declined in Proposals Aug 10, 2022
@rsc rsc added this to Proposals Aug 10, 2022
@rsc rsc removed this from Proposals Oct 19, 2022
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