For years I couldn't understand why Go — a language loved for its simplicity and performance — still doesn't have a professional GUI ecosystem. Every time I needed graphics in Go, I hit the same walls: CGO requirements, abandoned projects, incomplete solutions. It was frustrating.
Six months ago, I started preparing. Reading WebGPU specs, studying wgpu and naga source code, designing architecture. I was waiting for the right moment.
Then I saw this Reddit thread. Hundreds of developers sharing the same frustration. That was my trigger.
I published my first article with a simple triangle demo and started coding.
Two weeks later: 100,000+ lines of pure Go.
What We Built
Four repositories. Zero CGO. Just go build.
gogpu/gogpu (v0.3.0) — Graphics Framework
8,900 lines | GitHub
The main framework with dual backend architecture — choose performance or simplicity:
package main
import (
"github.com/gogpu/gogpu"
"github.com/gogpu/gogpu/gmath"
)
func main() {
app := gogpu.NewApp(gogpu.DefaultConfig().
WithTitle("Hello GoGPU").
WithSize(800, 600))
app.OnDraw(func(ctx *gogpu.Context) {
ctx.DrawTriangleColor(gmath.DarkGray)
})
app.Run()
}
Build tags for backend selection:
go build ./... # Both backends
go build -tags rust ./... # Rust backend (max performance)
go build -tags purego ./... # Pure Go backend (zero dependencies)
gogpu/wgpu (v0.4.0) — Pure Go WebGPU
57,900 lines | GitHub
Complete WebGPU implementation. No wgpu-native, no CGO:
| Component | Lines | Description |
|---|---|---|
| types/ | ~2K | WebGPU type definitions |
| core/ | ~6K | Validation and state tracking |
| hal/vulkan/ | ~35K | Vulkan 1.3 backend |
| hal/gles/ | ~7.5K | OpenGL ES backend |
| hal/software/ | ~1K | CPU rendering for CI/CD |
Three backends:
- Vulkan — Windows, Linux, macOS. Auto-generated bindings, buddy memory allocator, Vulkan 1.3 dynamic rendering.
- OpenGL ES — Windows (WGL), Linux (EGL)
- Software — Headless rendering. No GPU required.
// CI/CD without GPU
import _ "github.com/gogpu/wgpu/hal/software"
pixels := surface.GetFramebuffer() // CPU-rendered pixels
gogpu/naga (v0.4.0) — Shader Compiler
16,100 lines | GitHub
WGSL → SPIR-V compiler. Pure Go, 136 tests:
source := `
@compute @workgroup_size(64)
fn main(@builtin(global_invocation_id) id: vec3<u32>) {
let index = id.x;
output[index] = input[index] * 2.0;
}
`
spirv, err := naga.Compile(source)
Vertex, fragment, compute shaders. Atomics, barriers, texture sampling. 50+ built-in functions.
gogpu/gg (v0.4.0) — 2D Graphics
23,400 lines | GitHub
Enterprise-grade 2D graphics. Inspired by fogleman/gg:
ctx := gg.NewContext(800, 600)
ctx.ClearWithColor(gg.White)
// Shapes
ctx.SetColor(gg.Hex("#3498db"))
ctx.DrawCircle(400, 300, 100)
ctx.Fill()
// Text with font fallback
source, _ := text.NewFontSourceFromFile("Roboto.ttf")
ctx.SetFont(source.Face(24))
ctx.DrawString("Hello, GoGPU!", 350, 305)
// Layers with blend modes
ctx.PushLayer(gg.BlendMultiply, 0.7)
ctx.SetColor(gg.Red)
ctx.DrawRectangle(350, 250, 100, 100)
ctx.Fill()
ctx.PopLayer()
ctx.SavePNG("output.png")
Canvas API, text rendering, images, clipping, 29 blend modes, layers, linear color space blending. 80%+ test coverage for core packages (blend, color, image, text).
The Numbers
| Metric | Value |
|---|---|
| Total Lines of Code | 106,295 |
| Repositories | 4 |
| Development Time | 2 weeks |
| External Dependencies | 0 |
| CGO Required | No |
| Platforms | Windows, Linux, macOS |
Architecture
┌─────────────────────────────────────────────────────────────┐
│ Your Application │
├─────────────────────────────────────────────────────────────┤
│ gogpu/ui (planned) │ gogpu/gg (2D) │
├─────────────────────────────────────────────────────────────┤
│ gogpu/gogpu (framework) │
│ Windowing, Input, GPU Abstraction │
├─────────────────────────────────────────────────────────────┤
│ Rust Backend (wgpu-native) │ Pure Go Backend (wgpu) │
├─────────────────────────────────────────────────────────────┤
│ gogpu/naga (WGSL → SPIR-V) │
├─────────────────────────────────────────────────────────────┤
│ Vulkan │ OpenGL ES │ Software │
└─────────────────────────────────────────────────────────────┘
Why Pure Go?
For developers:
-
go buildjust works - Cross-compilation is trivial
- Debugging stays in Go
For CI/CD:
- Software backend — no GPU needed
- Tests run in containers
- No driver hassle
For the ecosystem:
- Native tooling
- Standard profiling
- No CGO overhead
What's Next
gogpu/ui — GUI widget toolkit. The final piece.
Performance — SIMD, parallel rendering, GPU acceleration.
More backends — Metal, DX12.
Get Involved
Star the repos:
Try it:
go get github.com/gogpu/gg
Contribute: Metal/DX12 backends, docs, testing.
Acknowledgments
- Michael Fogleman — original gg library
- gfx-rs — wgpu and naga reference implementations
- r/golang community — for the push I needed
Years of frustration. Six months of preparation. Two weeks of coding.
100,000 lines of pure Go graphics code.
The GPU ecosystem Go deserves is being built.
GoGPU — github.com/gogpu
Top comments (0)