Quickstart
Create a workers-go project from the Cloudflare template, run it locally, and deploy it.
The fastest way to start is the Deploy to Cloudflare button, which creates and deploys a project for you — no local setup required.
To create a project manually, follow the steps below.
Requirements
- Node.js (and npm)
- Go 1.24.0 or later
Create a project
Create a new Worker project
Scaffold a project from the worker-go template.
npm create cloudflare@latest -- --template github.com/syumai/workers-go/_templates/cloudflare/worker-goFor a smaller Wasm binary, use the TinyGo template instead. It requires TinyGo 0.42.0 or later — TinyGo 0.41.x cannot build net/http for Wasm.
npm create cloudflare@latest -- --template github.com/syumai/workers-go/_templates/cloudflare/worker-tinygoInitialize Go modules
cd my-app
go mod init
go mod tidyStart the dev server
npm startVerify the worker
curl http://localhost:8787/helloYou will see “Hello!” as the response.
Write your handler
Implement an http.Handler and pass it to workers.Serve().
package main
import (
"net/http"
"github.com/syumai/workers-go"
)
func main() {
http.HandleFunc("/hello", func(w http.ResponseWriter, req *http.Request) {
w.Write([]byte("Hello!"))
})
workers.Serve(nil) // if nil is given, http.DefaultServeMux is used
}
Deploy
npm run deploy
The build pipeline of the template compiles your Go code to Wasm and copies the runtime assets — see Build and deploy for how it works under the hood.