1
0
Fork 0
mirror of https://github.com/imjasonh/gocf synced 2026-07-07 02:22:17 +00:00
gocf/README.md
Jason Hall c4c28705e0 initial commit
Signed-off-by: Jason Hall <jason@chainguard.dev>
2026-01-07 11:02:40 -05:00

1.4 KiB

gocf - Cloudflare Workers in Go

Cloudflare Worker application written in Go, compiled to WASM, with access to KV, R2, D1, and Durable Objects.

Prerequisites

Setup

  1. Install dependencies:
go mod download
  1. Configure your bindings in wrangler.toml:
    • Create and configure KV namespace (need the ID)
    • Create an R2 bucket (need the name)
    • Create and configure D1 database (need the ID)
    • Configure Durable Objects as needed

Development

Build and run locally:

make dev

Deployment

Using Wrangler CLI

Deploy to Cloudflare:

make deploy

API Endpoints

  • GET / - Root endpoint showing available routes
  • GET /kv?key=<key> - Get value from KV
  • PUT /kv?key=<key>&value=<value> - Set key-value in KV
  • DELETE /kv?key=<key> - Delete key from KV
  • GET /r2?key=<key> - Get object from R2
  • PUT /r2?key=<key> - Put object to R2 (body is the content)
  • GET /d1 - Query D1 database
  • GET /do - Interact with Durable Object

Project Structure

  • main.go - Worker handler with KV, R2, D1, and DO examples
  • wrangler.toml - Cloudflare configuration
  • Makefile - Build commands using workers-assets-gen

Resources