This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user