diff options
| author | demo <demo@antix1> | 2026-05-24 10:01:53 -0400 |
|---|---|---|
| committer | demo <demo@antix1> | 2026-05-24 10:01:53 -0400 |
| commit | 67e7ebf8c507f2f02cff0866e3ccf48032f20b16 (patch) | |
| tree | 09f29379b0d042d9e7ca73c67a8cb9d3ffdd67d7 /main.go | |
| parent | 8a58972359906787fdd612246d220c2ffe0b0974 (diff) | |
refactor: move game code into testable function
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -12,6 +12,10 @@ func main() { numSecs := flag.Int("s", 1, "Number of seconds game should last") flag.Parse() + game(*numSecs) +} + +func game(numSecs int) { table := make(chan Ball) go player("ping", table) go player("pong", table) @@ -19,7 +23,7 @@ func main() { table <- Ball{} // Make the game last this long. - time.Sleep(time.Duration(*numSecs) * time.Second) + time.Sleep(time.Duration(numSecs) * time.Second) // Game over: grab the ball. <-table |
