Skip to content
workers-go
Esc
navigateopen⌘Jpreview

Experimental — APIs may change between releases

Run Go on Cloudflare Workers, and beyond

Your Go code compiles to WebAssembly, and workers-go bridges the JavaScript runtime APIs to idiomatic Go types.

$go get github.com/syumai/workers-go

One handler, every runtime

Write a plain http.Handler. workers-go serves it on Cloudflare Workers, in the browser, on Neon Functions, and on Deno.

package main

import (
	"fmt"
	"net/http"

	"github.com/syumai/workers-go"
)

func main() {
	http.HandleFunc("/hello", func(w http.ResponseWriter, req *http.Request) {
		fmt.Fprintf(w, "Hello, %s!", req.URL.Query().Get("name"))
	})
	workers.Serve(nil) // if nil is given, http.DefaultServeMux is used
}

The Workers platform, from Go

Bindings and triggers for the runtime APIs — stable where it matters, experimental where the platform is still moving.

  • http.Handler, unchanged
  • KV, R2, D1, and the Cache API
  • Queues, Cron, and FetchEvent
  • Durable Objects, WebSocket, RPC, and Workflows
  • TCP Sockets and Service Bindings
  • Workers AI, Vectorize, and Images
Explore the Cloudflare APIs

Deploy your first worker in minutes

Scaffold a project from the Cloudflare template, write an http.Handler, and ship it.

Quickstart