GoGPU: A Pure Go Graphics Library for GPU Programming

Published: (December 5, 2025 at 02:00 PM EST)
3 min read
Source: Dev.to

Source: Dev.to

The Problem: Go and Graphics Don’t Mix (Until Now)

If you’ve ever tried graphics programming in Go, you know the pain:

  • CGO hell – most libraries require a C compiler.
  • Abandoned projects – promising repos with no updates since 2019.
  • “Just use Rust/C++” – the default answer in every forum.

A Reddit thread about Go GUI development received hundreds of up‑votes and dozens of comments, all asking:

“Why can’t we have nice things in Go?”

That frustration inspired GoGPU, a pure‑Go GPU computing ecosystem designed to make graphics programming accessible to every Go developer.

Principles

Zero‑CGO

No C compiler required. Pure Go bindings via FFI.

WebGPU‑First

Modern API that works on Vulkan, Metal, DX12, with future WASM support.

Simple by Default

Easy things are easy. Hard things are possible.

Cross‑Platform

Windows today; macOS and Linux coming soon.

Example: Drawing a Colored Triangle

package main

import (
	"log"

	"github.com/gogpu/gogpu"
	"github.com/gogpu/gogpu/math"
)

func main() {
	app := gogpu.NewApp(gogpu.DefaultConfig().
		WithTitle("GoGPU Triangle").
		WithSize(800, 600))

	app.OnDraw(func(ctx *gogpu.Context) {
		ctx.DrawTriangleColor(math.DarkGray)
	})

	if err := app.Run(); err != nil {
		log.Fatal(err)
	}
}

Only 15 lines of Go code – the equivalent raw WebGPU code would be 400–500 lines of boilerplate.

GoGPU handles:

  • Window creation and event loop
  • GPU device initialization
  • Surface configuration
  • Shader compilation
  • Render pipeline setup
  • Frame presentation

You focus on what to draw; GoGPU handles how.

Architecture Overview

┌─────────────────────────────────────────┐
│           Your Application              │
│         (15 lines of code)              │
├─────────────────────────────────────────┤
│             gogpu/gogpu                 │
│         Graphics Framework              │
├─────────────────────────────────────────┤
│             gogpu/naga                  │
│    Shader Compiler (WGSL → SPIR‑V)      │
├─────────────────────────────────────────┤
│          go-webgpu/webgpu               │
│       Pure Go WebGPU Bindings           │
├─────────────────────────────────────────┤
│          go-webgpu/goffi                │
│        Pure Go FFI (Zero‑CGO)           │
├─────────────────────────────────────────┤
│            wgpu-native                  │
│       Vulkan / Metal / DX12             │
└─────────────────────────────────────────┘

The key innovation is goffi – a pure‑Go FFI library that lets us call native code without CGO, eliminating the need for a C compiler and simplifying builds.

Ecosystem and Dependencies

  • GPU & Graphics

    • Born ML – machine‑learning framework with GPU compute
    • go-webgpu/webgpu – the WebGPU bindings powering GoGPU
  • Systems & Libraries

    • Phoenix TUI – terminal UI framework
    • scigolib/hdf5 – scientific computing bindings
    • scigolib/matlab – MATLAB‑like operations
    • coregx/* – signals, state replication, functional reactive streams, regex utilities
    • kolkov/racedetector – race‑condition tools

These battle‑tested projects form the foundation on which GoGPU is built.

Version Milestones

VersionMilestoneStatus
v0.0.xProject structure✅ Done
v0.1.0‑alphaTriangle rendering✅ Done
v0.2.0‑alphaTextures & sprites🔄 Next
v0.3.0‑alphaText rendering📋 Planned
v0.5.0‑betaAPI stabilization📋 Planned
v1.0.0Production ready🎯 Goal

Repository Overview

RepositoryPurposeStatus
gogpu/gogpuCore graphics frameworkActive
gogpu/nagaShader compilerActive
gogpu/gg2D graphics APIPlanned
gogpu/uiGUI toolkitFuture

All repositories are hosted under the github.com/gogpu organization.

WebGPU Is the Future

  • Cross‑platform by design – same API on Windows, macOS, Linux, and browsers.
  • Modern architecture – built on lessons from Vulkan, Metal, and DX12.
  • Safe by default – validation prevents common GPU programming errors.
  • Browser‑ready – code can run in WASM (future goal).

Current Status

  • Version: v0.1.0‑alpha (early development)
  • Platform: Windows (macOS/Linux stubs ready)
  • API: Still evolving; breaking changes expected.

The architecture is solid, the triangle renders, and the foundation (go‑webgpu) is proven.

Getting Started

git clone https://github.com/gogpu/gogpu
cd gogpu
go run ./examples/triangle

Contributing

Open issues and pull requests are welcome, especially for:

  • macOS platform support
  • Linux platform support
  • Documentation
  • More examples

See the repository’s contribution guidelines for details.

Closing

Go deserves a great graphics library. Let’s build it together.
Questions? Drop them in the comments.

Back to Blog

Related posts

Read more »

Show HN: SerpApi MCP Server

Article URL: https://github.com/serpapi/serpapi-mcp Comments URL: https://news.ycombinator.com/item?id=46165251 Points: 4 Comments: 1...