- This project has been moved into workers repository.
Legacy Docmentation
- A template for starting a Cloudflare Worker project with Go.
- This template uses
workerspackage to run an HTTP server.
- A free plan Cloudflare Workers only accepts ~1MB sized workers.
- Go Wasm binaries easily exceeds this limit, so you'll need to use a paid plan of Cloudflare Workers (which accepts ~5MB sized workers).
main.goincludes simple HTTP server implementation. Feel free to edit this code and implement your own HTTP server.
- Node.js
- wrangler
- just run
npm install -g wrangler
- just run
- Go
$ git clone https://github.com/syumai/worker-template-go my-app
$ cd my-app
$ go mod init
$ go mod tidy
$ make dev # start running dev server
$ curl http://localhost:8787/hello
Hello!
- To change worker name, please edit
nameproperty inwrangler.toml.
make dev # run dev server
make build # build Go Wasm binary
make publish # publish worker
- Just send HTTP request using some tools like curl.
$ curl http://localhost:8787/hello
Hello!
$ curl -X POST -d "test message" http://localhost:8787/echo
test message