-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat: POD Go library #33
base: main
Are you sure you want to change the base?
Conversation
…ree types and neg values do not work yet
return json.Unmarshal(v, &p.boolVal) | ||
case "int": | ||
p.kind = "int" | ||
return json.Unmarshal(v, &p.intVal) |
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 am fairly sure that this will not work consistently with PODs serialized using our JavaScript library.
The JavaScript POD library can emit multiple representations for each POD value type, and so a compliant deserialization library must, in theory, support all of them. In the case of int values, this is not just a theoretical concern, as the default behaviour of the JavaScript POD library is to change the representation depending on the size and sign of the integer.
- If the integer is below 56 bits in size, then the JSON number type is used
- If the integer is above 56 bits in size, and positive, then a hexadecimal string is used
- If the integer is above 56 bits in size, and negative, then a decimal string is used
The difficulty of implementing compliant deserialization libraries was one of the points of discussion when this was originally implemented. I suspect that our Rust implementation is also not compatible with the JavaScript one.
This PR adds a new Go library for the POD specification, and an example HTTP server application. Currently, the following fields are supported, with more support for types incoming.
POD operations are extremely fast, with signing and verification operations in a 500µs - 2ms range, benchmarked on a 2022 Macbook Pro with an M1 chip.
You can test a deployed version of the HTTP server under gopod.onrender.com. Sample commands for testing.