goavro
goavro copied to clipboard
UUID Logical Type Support
I've encountered a case where it would have been helpful to validate that a string in a field, {"type": ["null", {"type": "string", "logicalType": "uuid"}], "default": null}
, was in fact a uuid.
To accomplish this, I've added two functions: nativeFromUUID
and uuidFromNative
. Both of these functions use uuid.Parse to validate that an outgoing or incoming string is a UUID. I went this route rather than using a regex because I found a gist that showed that google's uuid.Parse was much faster. Hopefully, the project is not too opposed to introducing a new package, but I am happy to hear objections.
Please let me know if there's any changes I should make; I hope this is a useful contribution!