Added CompleteCode function.
All checks were successful
CI / test (push) Successful in 17s

This commit is contained in:
2026-02-21 04:19:19 +01:00
parent 50e9036400
commit 22ca29b4af
5 changed files with 110 additions and 10 deletions

View File

@@ -6,6 +6,7 @@ import (
"crypto/rand"
"encoding/binary"
"errors"
"flag"
"fmt"
"git.hoiting.org/micha/triplex/serial"
@@ -29,6 +30,21 @@ func myRandomIndex(max uint32) (uint32, error) {
}
func main() {
complete := flag.String("complete", "", "complete code without checksum in format LLL-NNN-L")
flag.Parse()
if *complete != "" {
full, idx, err := serial.CompleteCode(*complete)
if err != nil {
fmt.Println("complete error:", err)
return
}
fmt.Println("code:", full)
fmt.Println("idx:", idx)
return
}
opts := serial.RandomCodeOptions{
MaxAttempts: 500,
IsInUse: func(idx uint32) bool {