-
Notifications
You must be signed in to change notification settings - Fork 373
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(examples): add package cford32, add method seqid.ID.String
#1572
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1572 +/- ##
==========================================
+ Coverage 44.31% 47.41% +3.10%
==========================================
Files 438 385 -53
Lines 66019 61319 -4700
==========================================
- Hits 29255 29074 -181
+ Misses 34341 29826 -4515
+ Partials 2423 2419 -4 ☔ View full report in Codecov by Sentry. |
Pull request #1572 marks the codeowner as @moul, in spite of what the configuration might suggest to a human reader. [Reading through GitHub's docs](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners#example-of-a-codeowners-file), this seems to come from the fact that if directories are not prefixed with a `/`, they are considered as applying to all files or directories with that name. (ie. `foo` matches `/foo` but also `/src/foo`). I've added `/` to all directories in CODEOWNERS to fix this.
Pull request gnolang#1572 marks the codeowner as @moul, in spite of what the configuration might suggest to a human reader. [Reading through GitHub's docs](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners#example-of-a-codeowners-file), this seems to come from the fact that if directories are not prefixed with a `/`, they are considered as applying to all files or directories with that name. (ie. `foo` matches `/foo` but also `/src/foo`). I've added `/` to all directories in CODEOWNERS to fix this.
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.
Looks great 💯
Not much to add in terms of reviewing, the package looks solid. Thank you for adding a new example package 🙏
…olang#1572) This PR adds a new package to examples, `cford32`, meant primarily to be used in package `seqid` as an AVL- and human-friendly ID, which implements an encoding scheme with the base32 encoding scheme [specified by Douglas Crockford](https://www.crockford.com/base32.html). It additionally implements a `uint64` encoding scheme I created, which encodes "tiny" (< 17 billion) values as 7-byte strings, and can encode the full `uint64` range with 13 bytes. The package is largely a fork of Go's `encoding/base32`, intentionally forked to have a very familiar API, while needing to be forked to implement some distinctive features of the encoding (like case insensitivity, and mapping in decoding all of the symbols `l L i I 1` to the same value). The necessity of this package comes from a solution that I implemented in GnoChess: https://github.com/gnolang/gnochess/blob/9aa813fbb86fec377a85fc4528411d652fc780ff/realm/chess.gno#L286-L295 Essentially, GnoChess used simple sequential IDs for its saved entities (like games). To work well with AVL's sorted keys, it padded the generated strings to the left with up to 9 zeroes. This, of course, breaks for values `>= 1e10` (10 billion), as `("2" + "000000000") > ("10" + "000000000")`.
This PR adds a new package to examples,
cford32
, meant primarily to be used in packageseqid
as an AVL- and human-friendly ID, which implements an encoding scheme with the base32 encoding scheme specified by Douglas Crockford. It additionally implements auint64
encoding scheme I created, which encodes "tiny" (< 17 billion) values as 7-byte strings, and can encode the fulluint64
range with 13 bytes.The package is largely a fork of Go's
encoding/base32
, intentionally forked to have a very familiar API, while needing to be forked to implement some distinctive features of the encoding (like case insensitivity, and mapping in decoding all of the symbolsl L i I 1
to the same value).The necessity of this package comes from a solution that I implemented in GnoChess:
https://github.com/gnolang/gnochess/blob/9aa813fbb86fec377a85fc4528411d652fc780ff/realm/chess.gno#L286-L295
Essentially, GnoChess used simple sequential IDs for its saved entities (like games). To work well with AVL's sorted keys, it padded the generated strings to the left with up to 9 zeroes. This, of course, breaks for values
>= 1e10
(10 billion), as("2" + "000000000") > ("10" + "000000000")
.