-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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 doesn't support recursive structs #20013
Comments
/cc @crawshaw |
You can't do it. This is essentially a dup of #16522. Since you can't build a named type with reflect, you can't build a self-referential type. |
@ianlancetaylor I don't see how this is essentially a dupe, though it is certainly related (and blocked on) #16522. With #16522 you could do
but without a mechanism for forward declaration, as mentioned in the OP, how do you add a field to (A related concern came up in #4146 where you would need |
s := reflect.StructOf(someFields) //want this to contain n but n doesn't exist yet |
If accepted and implemented, proposal #39528 would solve this |
go version: 1.8
I've been playing with
StructOf
to build go values that match a serialized schema-driven form.I've encountered an edge case that I'm uncertain whether Go currently supports. Given the struct:
I see no way to forward-declare the
S
struct to use it as a pointer field toStructOf
.Is there some way I can build this struct type?
The text was updated successfully, but these errors were encountered: