-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: encoding/gob: RegisteredTypes method #71602
Comments
Related Documentation (Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.) |
Starting from Go 1.23, direct access to `encoding/gob.nameToConcreteType` is no longer possible due to the removal of internal symbol linking. While this change improves encapsulation, it also removes the ability to retrieve a list of all registered types in the gob package. Relates: golang#67401 Closes: golang#71602
Change https://go.dev/cl/647536 mentions this issue: |
Maybe it should return an iter.Seq instead? |
Sounds good, I think it would be even better with iter.Seq |
can you point to existing open source code that would make use of this function instead of the alternate approaches (wrapping register, or debug builds using linkname) |
Starting from Go 1.23, direct access to `encoding/gob.nameToConcreteType` is no longer possible due to the removal of internal symbol linking. While this change improves encapsulation, it also removes the ability to retrieve a list of all registered types in the gob package. Relates: golang#67401 Closes: golang#71602 []string -> iter.Seq2[string, reflect.Type]
Per what I understand - you can now only use a wrapped registry for this case.
We use this inside our private repo-s to ensure consistency between worker and agent nodes, this is exposed as test and as cli-command for hand-on debugging on a machine. I don't know any open-source project that use this. |
…ype` is no longer possible due to the removal of internal symbol linking. While this change improves encapsulation, it also removes the ability to retrieve a list of all registered types in the gob package. Relates: golang#67401 Closes: golang#71602
Please update this proposal with the latest API that you implemented in the patch; the proposal here is for This seems reasonable enough to me; I expect use cases to be relatively rare, but I also don't see the danger in exposing such an API, and I agree that it's rather difficult to do this yourself - particularly as other packages or existing code may be registering types with gob directly. |
@mvdan done, re-worded proposal to |
Starting from Go 1.23, direct access to `encoding/gob.nameToConcreteType` is no longer possible due to the removal of internal symbol linking. While this change improves encapsulation, it also removes the ability to retrieve a list of all registered types in the gob package. Relates: golang#67401 Closes: golang#71602
Proposal Details
Description:
Starting from Go 1.23, direct access to
encoding/gob.nameToConcreteType
is no longer possible due to the removal of internal symbol linking. While this change improves encapsulation, it also removes the ability to retrieve a list of all registered types in thegob
package.I propose adding a new function:
Use Case
Many applications rely on reflection or introspection to determine which types have been registered with
gob.Register
. Without access to this list, debugging serialization issues or dynamically inspecting registered types becomes more difficult.For example here is how we track that
gob.Registry
is stable (since we rely on it to communicate between worker and agent). Agent and worker may be a separate binaries, so if agent has some missed type in registry - it will fail to start.Instead of this, there would be a dedicated
gob.RegisteredTypes
with all binary known types.Proposed Implementation
Internally,
gob.Register
already maintains a map of registered types. The newRegisteredTypes
function would simply iterate over this map and return a list of registered types with their names.Alternative Workarounds
Currently, developers need to maintain their own registry manually, which adds extra level of abstraction on top of
gob.Register
with unnecessary complexity and risks inconsistency.Would the Go team consider adding this function to restore this functionality in an officially supported way?
The text was updated successfully, but these errors were encountered: