aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Wang2022-03-28 11:51:19 -0500
committerAnthony Wang2022-03-28 11:51:19 -0500
commit24d27437208170463abb81819f4d0b2f45544d0b (patch)
tree47833877e093bcf0a5c0d0ef994af3d5519a0e46
parent8d3e071c9e076a038b286520837c5db4212c8e84 (diff)
Verbose logging
-rw-r--r--sd.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/sd.go b/sd.go
index d1a6756..fbbd8b9 100644
--- a/sd.go
+++ b/sd.go
@@ -11,6 +11,7 @@ import (
_ "modernc.org/sqlite"
)
+var verbose = flag.Bool("v", false, "debug output")
var file = flag.String("f", "cards", "cards file")
var sum = 0
@@ -76,6 +77,11 @@ func main() {
build(rows, 0, N-1, 1)
rows.Close()
+ if *verbose {
+ fmt.Println(N)
+ fmt.Println(seg)
+ }
+
// https://stackoverflow.com/questions/14094190/function-similar-to-getchar
// disable input buffering
exec.Command("stty", "-F", "/dev/tty", "cbreak", "min", "1").Run()
@@ -87,8 +93,10 @@ func main() {
for {
// Choose a random card
x := rand.Intn(sum)
- fmt.Println(sum)
- fmt.Println(x)
+ if *verbose {
+ fmt.Println(sum)
+ fmt.Println(x)
+ }
w, i := query(x, 0, N-1, 1)
fmt.Println(w)
fmt.Println(i)