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

proposal: reflect: allow to create methods for structs at runtime #20736

Closed
audathuynh opened this issue Jun 20, 2017 · 2 comments
Closed

proposal: reflect: allow to create methods for structs at runtime #20736

audathuynh opened this issue Jun 20, 2017 · 2 comments

Comments

@audathuynh
Copy link

Currently, we can create a struct with embedded fields at runtime.
However, we cannot create methods for structs at runtime.

Below is the statement on the website of Go (https://golang.org/pkg/reflect/#StructOf).
"StructOf currently does not generate wrapper methods for embedded fields. This limitation may be lifted in a future version."

In practice, we may need to create a struct instance to implement the methods of some interfaces.
I would recommend that this feature should be implemented in Go.

What version of Go are you using (go version)?

1.8.3

@gopherbot gopherbot added this to the Proposal milestone Jun 20, 2017
@ALTree
Copy link
Member

ALTree commented Jun 20, 2017

Generating those wrappers is #15924
Creating and attaching methods at runtime is #16522

@josharian
Copy link
Contributor

Closing as duplicate. Please comment if that is incorrect.

@golang golang locked and limited conversation to collaborators Jun 20, 2018
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