This commit is contained in:
11
README.md
11
README.md
@@ -9,7 +9,7 @@ Copyright (c) 2026 Micha Hoiting
|
||||
high-integrity identifiers. It maps a compact 32-bit integer space to a
|
||||
human-readable serial format:
|
||||
|
||||
```
|
||||
```text
|
||||
LLL-NNN-LC
|
||||
```
|
||||
|
||||
@@ -18,6 +18,12 @@ Where:
|
||||
- `N` = number (`100`–`999`)
|
||||
- `C` = checksum letter (`A`–`Z`)
|
||||
|
||||
For instance
|
||||
|
||||
```text
|
||||
ABC-123-DT
|
||||
```
|
||||
|
||||
## What it provides
|
||||
|
||||
- 4 data letters
|
||||
@@ -77,6 +83,8 @@ func main() {
|
||||
- Parses and validates `LLL-NNN-LC`, checks checksum, and returns the deterministic index.
|
||||
- `serial.Decode(idx uint32) (string, error)`
|
||||
- Converts a valid index back to `LLL-NNN-LC`.
|
||||
- `serial.CompleteCode(codeWithoutChecksum string) (string, uint32, error)`
|
||||
- Takes `LLL-NNN-L` and returns the completed `LLL-NNN-LC` plus index.
|
||||
- `serial.RandomCode(isInUse ...func(uint32) bool) (string, uint32, error)`
|
||||
- Generates a random valid `LLL-NNN-LC` code and its corresponding index.
|
||||
- If provided, the callback is used to skip indices already in use by the client.
|
||||
@@ -108,6 +116,7 @@ make test
|
||||
Exported errors:
|
||||
|
||||
- `serial.ErrInvalidFormat`
|
||||
- `serial.ErrInvalidFormatNoChecksum`
|
||||
- `serial.ErrInvalidLetters`
|
||||
- `serial.ErrForbiddenLetterTriplet`
|
||||
- `serial.ErrInvalidNumber`
|
||||
|
||||
Reference in New Issue
Block a user