go-reddit

A pure-Go (CGO=0) Reddit client and a native macOS reader built on it โ€” stdlib only, static binaries, no cgo.

pure Go ยท zero cgo stdlib-only client anonymous or OAuth typed *APIError every sort & time window nested comments go-widgets UI purego WKWebView reader:// scheme ยท no port 100% coverage 6 arches
Documentation reddit reader
Documentation (MkDocs Material + mike) License: BSD-3-Clause Go 1.26.4+ Coverage 100%

go-reddit is a small, dependency-free stack for reading Reddit from Go. At the bottom, reddit is a stdlib-only, CGO_ENABLED=0 client for Reddit's JSON API โ€” subreddit, front-page and comment listings across every sort and time window, read anonymously or over OAuth, with non-2xx responses surfaced as a typed *APIError. On top of it, reader is a native macOS app whose entire UI is painted by the go-widgets toolkit, compiled to WebAssembly, blitted into a <canvas>, and hosted in a WKWebView opened from Go with zero cgo via purego โ€” served over a private reader:// URL scheme with no socket and no listening port. Every module is pure Go, cross-compiles to all six 64-bit Go targets, and ships as a single static binary at 100% coverage.

reddit โ€” API client ready

A stdlib-only, CGO_ENABLED=0 client for Reddit’s JSON API: subreddit, front-page and comment listings across every sort (hot/new/top/rising/controversial/best) and time window, with cursor paging and recursively-nested comment replies.

Anonymous or OAuth ready

Read public listings anonymously, or authenticate with the app-only (client_credentials) or script (password) grant โ€” the reliable path now that Reddit blocks anonymous .json from datacenter IPs with a 403. Bearer tokens are fetched, cached and refreshed automatically over oauth.reddit.com.

Typed errors ready

Non-2xx responses surface as a typed *reddit.APIError carrying the status code, so callers can distinguish a 429 (rate limit) from a 403 (blocked) or a 404 (gone). 100% coverage, every error branch included.

reader โ€” native macOS app ready

A Reddit reader whose entire UI โ€” topbar sort tabs, bookmarked-subreddit sidebar, scrollable post cards โ€” is painted by the go-widgets toolkit into an RGBA buffer at device resolution, then compiled to WebAssembly and blitted into a <canvas>.

Zero-cgo WKWebView ready

The WKWebView, NSWindow and NSApplication are driven through the Objective-C runtime via purego โ€” the shipped binary links only system libraries, AppKit/WebKit are dlopened at runtime, and task app produces a double-clickable .app bundle. CGO_ENABLED=0 end to end.

No socket, no port ready

The default transport registers a private reader:// URL scheme and answers every request in-process from the same http.Handler via a WKURLSchemeHandler โ€” no loopback server, no listening port. fetch reader://app/api/feed routes straight through go-reddit/reddit to reddit.com.

Two pure-Go modules, cgo disabled, so they cross-compile and embed anywhere. The client is stdlib-only; the reader drives AppKit / WebKit through the Objective-C runtime via purego, painting its UI with go-widgets and serving content in-process through a WKURLSchemeHandler. Validated at 100% coverage, gofmt + go vet clean, CI green across the six 64-bit Go arches โ€” see github.com/go-reddit.