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: structs with embedded members are unconstructable #65144

Closed
infogulch opened this issue Jan 18, 2024 · 1 comment
Closed

reflect: structs with embedded members are unconstructable #65144

infogulch opened this issue Jan 18, 2024 · 1 comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime.

Comments

@infogulch
Copy link
Contributor

infogulch commented Jan 18, 2024

Go version

gotip

What did you do?

I'm trying to create a struct with reflect that is equal to an existing struct that has embedded/anonymous fields.

What did you see happen?

I found that it is not possible to use reflect to create a struct with embedded/anonymous members.

Generally, it is possible to create a struct with reflect if all the fields are named, but not in this case where the fields are unnamed (embedded).

I created a playground snippet which I hope clearly demonstrates the issue, as well as what I expect to happen under normal circumstances:

https://go.dev/play/p/BmUv11ZJkay?v=gotip

What did you expect to see?

I expect it to be possible to build a struct with reflect that can be compared as equal to any existing struct with public members.

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jan 18, 2024
@seankhliao
Copy link
Member

Duplicate of #24781

@seankhliao seankhliao marked this as a duplicate of #24781 Jan 18, 2024
@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime.
Projects
None yet
Development

No branches or pull requests

3 participants