-
Notifications
You must be signed in to change notification settings - Fork 78
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
Expose types #292
base: master
Are you sure you want to change the base?
Expose types #292
Conversation
@@ -145,6 +145,18 @@ func NewCodec() *Codec { | |||
return cdc | |||
} | |||
|
|||
func (cdc *Codec) TypeInfos() map[reflect.Type]*TypeInfo { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have too much context here, but simply returning maps on a reference type is somewhat dangerous as the caller can unexpectedly modify the reference (i.e. the codec). Instead, return a copy of the map.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, let's add simple godocs.
Can we open an issue for this please? Also note there is the I'm not sure exactly the use case here, but if you don't need it programmatically, hopefully printing the table is sufficient. Otherwise you will need to grab the mutex and copy the map, as bez pointed out |
This was some quick hacking I did one afternoon to try to expose the types tracked by amino in a I believe that Hans is working on this so I would like to check with him before closing/doing more work. |
Oh cool - would a method that just dumps JSON be sufficient then? Might be easier than trying to programmatically export the mutex protected maps ... |
@ebuchman I think it would. How to do that with the existing code? This also could be useful for generating |
Replaces #291