Comments (3)
My output for the test case for the typescript implementation https://github.com/ongteckwu/typeid-ts matches this repo's.
from typeid-go.
@alisa101rs Thanks for reporting.
I ran two tests:
- I tried the encoding using
ulid
(which uses the same alphabet), it matched - I tried the encoding using
go
s standard base32 library, but with the custom alphabet ... it did not match.
So there's a discrepancy between the two approaches. I'm doing some more testing to determine what should be the "right" way to encode typeids and will clarify the spec. I'll circle back.
from typeid-go.
OK, I did a bunch of testing, and I think the original implementation in this repo is still correct.
In particular the current implementation aligns the encoding of the typeid in an intuitive way with UUIDs. So that,
the typeid prefix_00000000000000000000000001
corresponds to the UUID 00000000-0000-0000-0000-000000000001
. I added a test to check for that here: https://github.com/jetpack-io/typeid-go/blob/main/typeid_test.go#L100
Note that the standard base32 algorithm works in groups of 5 bytes, and therefore is subject to add padding at the end
of the byte array one is trying to decode. In our case though, we use an algorithm without padding that works byte by byte; to make the standard base32 algorithm work, padding would have to be added to the front of the array.
I added a test to validate that here: https://github.com/jetpack-io/typeid-go/blob/main/base32/base32_test.go#L11
from typeid-go.
Related Issues (7)
- Update `uuid` package HOT 1
- implement the standard interfaces HOT 3
- Define binary representation for TypeIDs and implement binary marshaling
- Should the golang implementation implement the SQL Valuer interface? HOT 7
- Generics drastically increased my integration of typeid HOT 1
- Type error after upgrading to 1.0.0 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typeid-go.