April 8, 2026
No more sleep loops, just drama
Show HN: Go-Bt: Minimalist Behavior Trees for Go
Go devs cheer “robot brain” for jobs while skeptics yell “just use state machines”
TLDR: Go-bt debuts as a minimalist “robot brain” for Go that avoids sleep loops and fast‑forwards tests with a mocked clock. The crowd loves the testing magic, but a fight erupts over Behavior Trees vs. state machines, with requests for parallelism and backoff keeping the debate spicy.
Go’s newest toy, go-bt, promises a “no more sleep loops” life: a tiny “robot brain” that checks tasks, reports back instantly (done, waiting, or failed), and lets a background supervisor keep things humming. Fans say it’s clean, fast, and perfect for background workers and game bots. Doubters? They’re already sharpening their pitchforks.
The loudest cheers are for the time‑travel testing trick—mocking the clock so unit tests can fast‑forward minutes in microseconds. One commenter called it “a really nice touch,” and folks are imagining fewer flaky tests and smoother retries in microservices. There’s also a wishlist forming: parallel nodes to run things side‑by‑side, and questions about whether the supervisor sticks to a fixed tick or supports backoff during “still running” states.
But the drama hits where it always does: Behavior Trees vs. State Machines. Behavior Trees (think flowchart‑style decision makers used in games—see what they are) get labeled “brute‑force” by one skeptic, who says state machines are easier to reason about once you express them as data. Meanwhile, fans argue the minimalist, stateless design with a shared context keeps things tidy and cancellation‑friendly. The memes? “No more time.Sleep, my boss thinks I work twice as fast” and “Finally, legal time travel for tests.” Classic internet energy: half honeymoon phase, half reality check.
Key Points
- •go-bt is a Behavior Tree library for Go designed for workers, game AI, automation, and async logic.
- •Nodes are stateless; execution state and temporal memory live in a generic BTContext[T] that embeds context.Context.
- •Each node returns 1 (Success), 0 (Running), or -1 (Failure), enabling cooperative multitasking without blocking.
- •The library includes composites (Selector, Sequence, MemSequence), decorators (Inverter, Optional, Timeout, Retry, Repeat), and leaves (Condition, Action, Sleep).
- •A panic-safe Supervisor ticks trees at fixed intervals, and an injectable clock enables instant, deterministic testing of time-based nodes.