-
Notifications
You must be signed in to change notification settings - Fork 30
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
Go: Use private interfaces instead of generating structs for discriminating types #67
Comments
If I can get this project to build locally in Nix, I will probably file a PR for this. |
diamondburned
added a commit
to diamondburned/json-typedef-codegen
that referenced
this issue
Feb 13, 2023
This commit implements jsontypedef/issues/67.
2 tasks
diamondburned
added a commit
to diamondburned/json-typedef-codegen
that referenced
this issue
Feb 13, 2023
This commit implements jsontypedef/issues/67.
diamondburned
added a commit
to diamondburned/json-typedef-codegen
that referenced
this issue
Feb 28, 2023
This commit implements jsontypedef/issues/67.
diamondburned
added a commit
to diamondburned/json-typedef-codegen
that referenced
this issue
Feb 28, 2023
This commit implements jsontypedef/issues/67.
diamondburned
added a commit
to diamondburned/json-typedef-codegen
that referenced
this issue
Feb 28, 2023
This commit implements jsontypedef/issues/67.
diamondburned
added a commit
to diamondburned/json-typedef-codegen
that referenced
this issue
Mar 1, 2023
This commit implements jsontypedef/issues/67.
diamondburned
added a commit
to diamondburned/json-typedef-codegen
that referenced
this issue
Mar 1, 2023
This commit implements jsontypedef/issues/67.
diamondburned
added a commit
to diamondburned/json-typedef-codegen
that referenced
this issue
Mar 2, 2023
This commit implements jsontypedef/issues/67.
diamondburned
added a commit
to diamondburned/json-typedef-codegen
that referenced
this issue
Mar 5, 2023
This commit implements jsontypedef/issues/67.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Proposal
This issue proposes that for the following JSON type definition:
jtd-codegen
should generate the following Go code:The user would consume the API like so:
If the user makes a mistake in the type-switch, the compiler will complain:
This issue is an alternative to issue #49.
Rationale
Pros:
memory if the mapping is large.
more idiomatic and safer in Go than using a string field.
Cons:
Value
is not ideal. This is done because we can'thave custom marshalers and unmarshalers on an interface.
exported type is not ideal.
TValue
outside a singlecomment. This might be confusing to users.
The text was updated successfully, but these errors were encountered: