Introduction
workers-go is a Go module that runs an HTTP server written in Go on Cloudflare Workers, Neon Functions, Deno, and in the browser.
workers-go is a Go module for running an http.Handler written in Go on Cloudflare Workers, on Neon Functions, on Deno / Deno Deploy, and, with the browser template, directly in the browser. Your Go code is compiled to WebAssembly, and this package bridges the JavaScript runtime APIs to idiomatic Go types.
Quickstart
Create and deploy your first worker in minutes.
Cloudflare
Serve http.Handler and use KV, R2, D1, Queues, Cron, and more.
Browser
Serve HTTP from a Go Wasm binary running in the browser.
Neon Functions
Serve http.Handler on Neon’s serverless functions platform.
Deno / Deno Deploy
Serve http.Handler via Deno.serve on Deno and Deno Deploy.
Platforms
This documentation is organized per platform. Each platform section explains how to use every supported feature.
- Cloudflare — run on Cloudflare Workers or Pages Functions, with bindings for KV, R2, D1, Durable Objects, Queues, Cron Triggers, the Cache API, Service Bindings, TCP Sockets, Workers RPC / named entrypoints, and Workflows.
- Browser — run the same
http.Handlerinside a browser tab using thebrowser-gotemplate. - Neon Functions — run the same
http.Handleron Neon’s serverless functions platform using thefunctions-tinygotemplate. - Deno / Deno Deploy — run the same
http.HandlerviaDeno.serveon Deno and Deno Deploy using theworker-gotemplate.
Feature support
| Feature | Status |
|---|---|
Serve http.Handler |
Stable |
| Environment variables and bindings | Stable |
| KV | Stable (method options are not fully implemented) |
| R2 | Stable (method options are not fully implemented) |
| Cache API | Stable |
| Durable Objects | Experimental — hosting a Go type as a Durable Object class (with SQL storage) and calling stubs |
| D1 | Experimental (alpha) |
| Queues (producer and consumer) | Stable |
| Cron Triggers | Stable |
FetchEvent (waitUntil, passThroughOnException) |
Stable |
| Outbound fetch and Service Bindings | Stable |
| TCP Sockets | Stable |
WebSocket (exp/cloudflare/websocket) |
Experimental |
Email Workers (exp/cloudflare/email) |
Experimental |
Tail Workers (exp/cloudflare/tail) |
Experimental |
Workflows (exp/cloudflare/workflows) |
Experimental — calling into a Workflow and hosting one (WorkflowEntrypoint) |
RPC / named entrypoints (exp/cloudflare/rpc) |
Experimental — calling a WorkerEntrypoint/Durable Object over RPC and hosting one |
Workers AI, Vectorize, Images, Analytics Engine, Hyperdrive, Secrets Store, Dispatch, Rate Limiting, Versions, request.cf (exp/cloudflare) |
Experimental |
Hono middleware (exp/hono) |
Experimental |
Installation
go get github.com/syumai/workers-go
Migrating from github.com/syumai/workers
To switch, rewrite the import paths and tidy:
# Linux
find . \( -name '*.go' -o -name go.mod \) -exec sed -i 's|github.com/syumai/workers\([/" ]\)|github.com/syumai/workers-go\1|g' {} +
# macOS
find . \( -name '*.go' -o -name go.mod \) -exec sed -i '' 's|github.com/syumai/workers\([/" ]\)|github.com/syumai/workers-go\1|g' {} +
go mod tidy