Various improvements.

This commit is contained in:
2026-02-21 00:34:57 +01:00
parent 8670c509e8
commit 09a1c8dd26
6 changed files with 160 additions and 11 deletions

View File

@@ -75,6 +75,30 @@ func main() {
- `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.
- `serial.RandomCodeWithOptions(options serial.RandomCodeOptions) (string, uint32, error)`
- Configurable variant with `MaxAttempts`, `IsInUse`, and custom `RandomIndex` source.
Example with options:
```go
// See the runnable command at ./cmd/triplex-example/main.go
```
## Commands
Runnable example command:
```bash
go run ./cmd/triplex-example
```
Using Makefile:
```bash
make run-example
make build-example
make test
```
Exported errors:
@@ -85,7 +109,8 @@ Exported errors:
- `serial.ErrNumberOutOfRange`
- `serial.ErrInvalidChecksum`
- `serial.ErrIndexOutOfRange`
- `serial.ErrRandomGenerationFailed`
- `serial.ErrRandomSourceFailed`
- `serial.ErrNoAvailableIndex`
## Testing