Go handles game development through third-party engines and libraries rather than a built-in engine. The most mature choice is Ebitengine, a 2D game library that runs on Windows, macOS, Linux, the web (WebAssembly), iOS and Android from one codebase. Go's goroutines, fast compile times and single-binary output suit tools, servers and 2D games well, while large 3D productions are still better served by C++, C# or Rust engines.
The standard library supplies images, audio decoding and timing, but no window, input or GPU layer, so you pick an engine for that. Most of the practice below applies to any of them.
| Library | Focus | Notes |
|---|---|---|
Ebitengine (github.com/hajimehoshi/ebiten/v2) | 2D games, all major platforms | Most active, good docs, simple API |
raylib-go (github.com/gen2brain/raylib-go) | 2D and basic 3D | Bindings to the C library raylib, needs cgo on some platforms |
Pixel (github.com/faiface/pixel) | 2D | Lightly maintained, check recent activity before choosing |
| g3n | 3D scene graph on OpenGL | Small community, suited to experiments |
Standard library image, image/draw, image/png | Software rendering, sprite tools | No window or input |
For a new 2D project, start with Ebitengine. For 3D, expect to write more yourself or to bind a C library, and check that the project is still maintained before you commit to it.
Ebitengine asks you to implement the ebiten.Game interface: Update advances logic, Draw renders a frame, and Layout defines the logical screen size. The engine calls Update at a fixed 60 ticks per second by default and Draw once per displayed frame.
Create a module with go mod init example.com/game, run go mod tidy, then go run .. Update and Draw are separate on purpose: logic stays deterministic, and drawing never changes state.
Go has no inheritance, so the classic "everything derives from GameObject" design does not fit. Two approaches work well.
Position or Sprite struct in entities and define narrow interfaces such as Updater and Drawer.github.com/mlange-42/arche provide this, and ECS keeps data contiguous, which helps the cache and the garbage collector.Keep the world state in one struct that Update owns. That makes save games, replays and tests straightforward, because you can serialise the state with encoding/json or encoding/gob.
Goroutines are useful for loading assets, pathfinding, networking and AI planning, but the render loop should stay on one goroutine. Most graphics APIs require calls from the main thread, and Ebitengine calls Update and Draw for you on its own schedule.
Update or Draw.context.Context to cancel background work when a level ends.go test -race on your logic code to catch data races early.The Go garbage collector is concurrent, with short pauses, but allocating in the per-frame path still causes jitter and wasted CPU. Practical rules:
s = s[:0] and preallocate with make([]T, 0, n).sync.Pool for short-lived objects such as bullets or particles when profiling shows allocation cost.SubImage so the engine can merge draw calls.fmt.Sprintf and string concatenation inside Draw.GOMEMLIMIT or debug.SetMemoryLimit if your target device is tight on RAM.Measure before optimising. Add net/http/pprof or write a CPU profile with runtime/pprof, and view it with go tool pprof. Ebitengine's ebiten.ActualFPS() and ebiten.ActualTPS() give a quick frame-rate check.
Go cross-compiles easily, but graphics and audio libraries can need cgo or platform packages. Check the Ebitengine documentation for the current per-platform requirements.
Embed assets with the embed package so the game ships as one file:
Decode it with image.Decode(bytes.NewReader(playerPNG)) and convert it with ebiten.NewImageFromImage.
It is a good fit for 2D games, game tools, level editors and multiplayer servers. It is a weaker fit for AAA 3D games, where mature engines and ecosystems exist in other languages.
Yes, with raylib-go, g3n or custom OpenGL and Vulkan bindings, but the tooling is thinner than in Unity, Unreal or Godot. Many teams write the game server in Go and the client elsewhere.
Go's collector pauses are short, and most frame-time problems come from allocating inside the update and draw paths. Reuse buffers and profile to keep pauses invisible.
Yes. Ebitengine supports WebAssembly, so you can build with GOOS=js GOARCH=wasm and serve the result with a small HTML page.
Go handles game development through libraries, with Ebitengine as the practical default for 2D on desktop, web and mobile. Keep logic and drawing separate, use composition or ECS instead of inheritance, keep rendering on one goroutine, avoid per-frame allocations, and profile with pprof. Embed assets and cross-compile to ship one binary per platform.