Skip to content

MarshalFunc and dynamic reflect.Type #168

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

Closed
torbenschinke opened this issue Apr 8, 2025 · 2 comments
Closed

MarshalFunc and dynamic reflect.Type #168

torbenschinke opened this issue Apr 8, 2025 · 2 comments

Comments

@torbenschinke
Copy link

I tried to adapt my enum package to the new v2 API, but I'm currently stuck on the json functions that only supports generic type parameters for defining custom marshalers/unmarshalers. Due to the dynamic discovery via reflect.Type, I can't instantiate the corresponding generic types.

It would only take a simple additional one-liner to also support a non-generic variant — similar to how the reflect package provides both TypeFor[T] and TypeOf(any).

@dsnet
Copy link
Collaborator

dsnet commented Apr 17, 2025

Hi, I recommend filing a proposal at https://github.com/golang/go/issues with the suggested API and tagging golang/go#71497 as the parent issue. Since this is API that could be added after the initial release of v2, I suspect that it will not be considered initially.

It seems to me that would need at least 4 additional functions to support this, which is somewhat unfortunate.

@torbenschinke
Copy link
Author

Thanks for the response. I’ve opened a proposal at golang/go#73457.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants