-
Notifications
You must be signed in to change notification settings - Fork 169
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
strict parsing by default #118
Comments
The performance might be the same, but what they do under the hood is different: Consider if you have the following 2 ulid's:
Test code: https://go.dev/play/p/4FtDFNoUAuk |
That's right. However, passing an invalid ULID to I believe this change is useful to prevent such mistakes. |
One issue would be that doing that would require to make a v3, in order to stay Backward Compatibility as normal in the Golang community. The docs statement of the performance is just a warning that if the strictness is not needed, you should just use the normal Parse. For me the naming gives away that there is a deliberate difference in how they work. I even doubted to make a bug report that ParseStrict is not working properly. Because looking the base32 specs states:
I never made a bug report, since I think this was done on purpose to fill a need for a stricter approach. That said maybe one of the maintainers could give some more insight in this? |
Calling ulid.Parse is how users verify if a ULID string is or isn't valid, so an invalid string is perfectly correct usage, you just get an error. |
@peterbourgon understandable, but @shogo82148 is suggesting that ulid.Parse should behave the same as ulid.ParseStrict since the performance penalty is no longer there. |
It raises broader questions, specifically I think the existing Parse is probably too strict, because it doesn't parse |
If it is after merging #116, there is no performance difference between
Parse
andParseStrict
.The reason for having
Parse
andParseStrict
separately disappears. Perhaps it would be acceptable to perform strict checks in Parse as well?The text was updated successfully, but these errors were encountered: