diff --git a/_examples/basic-auth-proxy/Makefile b/_examples/basic-auth-proxy/Makefile index 019492c2..3140ac9c 100644 --- a/_examples/basic-auth-proxy/Makefile +++ b/_examples/basic-auth-proxy/Makefile @@ -4,8 +4,8 @@ dev: .PHONY: build build: - go run ../../cmd/workers-assets-gen - tinygo build -o ./build/app.wasm -target wasm -no-debug ./... + go run ../../cmd/workers-assets-gen -mode=go + GOOS=js GOARCH=wasm go build -o ./build/app.wasm . .PHONY: deploy deploy: diff --git a/_examples/basic-auth-proxy/README.md b/_examples/basic-auth-proxy/README.md index 95c51ed4..d02b4194 100644 --- a/_examples/basic-auth-proxy/README.md +++ b/_examples/basic-auth-proxy/README.md @@ -17,12 +17,12 @@ This project requires these tools to be installed globally. * wrangler -* tinygo +* Go 1.24.0 or later ### Commands ``` make dev # run dev server make build # build Go Wasm binary -make deploy # deploy worker +make deploy # deploy worker ``` diff --git a/_examples/basic-auth-proxy/main.go b/_examples/basic-auth-proxy/main.go index 53529547..a9643d37 100644 --- a/_examples/basic-auth-proxy/main.go +++ b/_examples/basic-auth-proxy/main.go @@ -14,6 +14,10 @@ const ( userPassword = "password" ) +func canHaveBody(method string) bool { + return method != "GET" && method != "HEAD" && method != "" +} + func authenticate(req *http.Request) bool { username, password, ok := req.BasicAuth() return ok && username == userName && password == userPassword @@ -33,7 +37,16 @@ func handleRequest(w http.ResponseWriter, req *http.Request) { u := *req.URL u.Scheme = "https" u.Host = "syum.ai" - r, err := fetch.NewRequest(req.Context(), req.Method, u.String(), req.Body) + + // disallow setting body for GET and HEAD + // see https://github.com/whatwg/fetch/issues/551 + var r *fetch.Request + var err error + if canHaveBody(req.Method) { + r, err = fetch.NewRequest(req.Context(), req.Method, u.String(), req.Body) + } else { + r, err = fetch.NewRequest(req.Context(), req.Method, u.String(), nil) + } if err != nil { handleError(w, http.StatusInternalServerError, "Internal Error") log.Printf("failed to initialize proxy request: %v\n", err) diff --git a/_examples/cache/Makefile b/_examples/cache/Makefile index a73fac2e..3140ac9c 100644 --- a/_examples/cache/Makefile +++ b/_examples/cache/Makefile @@ -4,9 +4,8 @@ dev: .PHONY: build build: - go run ../../cmd/workers-assets-gen - #tinygo build -o ./build/app.wasm -target wasm -no-debug ./... - tinygo build -o ./build/app.wasm -target wasm -no-debug ./... + go run ../../cmd/workers-assets-gen -mode=go + GOOS=js GOARCH=wasm go build -o ./build/app.wasm . .PHONY: deploy deploy: diff --git a/_examples/cache/README.md b/_examples/cache/README.md index c5e1e29d..8930ecf1 100644 --- a/_examples/cache/README.md +++ b/_examples/cache/README.md @@ -9,12 +9,12 @@ The Cache API allows fine grained control of reading and writing from the Cloudf This project requires these tools to be installed globally. * wrangler -* tinygo +* Go 1.24.0 or later #### Commands ``` make dev # run dev server make build # build Go Wasm binary -make deploy # deploy worker +make deploy # deploy worker ``` \ No newline at end of file diff --git a/_examples/cache/main.go b/_examples/cache/main.go index 8f7c9fdc..13f2f588 100644 --- a/_examples/cache/main.go +++ b/_examples/cache/main.go @@ -12,6 +12,10 @@ import ( "github.com/syumai/workers/cloudflare/cache" ) +func canHaveBody(method string) bool { + return method != "GET" && method != "HEAD" && method != "" +} + type responseWriter struct { http.ResponseWriter StatusCode int @@ -40,6 +44,10 @@ func handler(w http.ResponseWriter, req *http.Request) { rw := responseWriter{ResponseWriter: w} c := cache.New() + if !canHaveBody(req.Method) { + req.Body = nil + } + // Find cache res, _ := c.Match(req, nil) if res != nil { diff --git a/_examples/cron/Makefile b/_examples/cron/Makefile index eaa93565..d0414390 100644 --- a/_examples/cron/Makefile +++ b/_examples/cron/Makefile @@ -4,8 +4,8 @@ dev: .PHONY: build build: - go run ../../cmd/workers-assets-gen - tinygo build -o ./build/app.wasm -target wasm -no-debug ./... + go run ../../cmd/workers-assets-gen -mode=go + GOOS=js GOARCH=wasm go build -o ./build/app.wasm . .PHONY: deploy deploy: diff --git a/_examples/cron/README.md b/_examples/cron/README.md index b31da2f7..e4f79ecc 100644 --- a/_examples/cron/README.md +++ b/_examples/cron/README.md @@ -9,14 +9,14 @@ This project requires these tools to be installed globally. * wrangler -* tinygo +* Go 1.24.0 or later ### Commands ``` make dev # run dev server make build # build Go Wasm binary -make deploy # deploy worker +make deploy # deploy worker ``` #### Testing cron schedule diff --git a/_examples/d1-blog-server/Makefile b/_examples/d1-blog-server/Makefile index 1e41aac6..76cebc20 100644 --- a/_examples/d1-blog-server/Makefile +++ b/_examples/d1-blog-server/Makefile @@ -4,16 +4,20 @@ dev: .PHONY: build build: - go run ../../cmd/workers-assets-gen - tinygo build -o ./build/app.wasm -target wasm -no-debug ./main.go + go run ../../cmd/workers-assets-gen -mode=go + GOOS=js GOARCH=wasm go build -o ./build/app.wasm . .PHONY: deploy deploy: wrangler deploy +.PHONY: create-db +create-db: + wrangler d1 create d1-blog-server + .PHONY: init-db init-db: - wrangler d1 execute d1-blog-server --file=./schema.sql + wrangler d1 execute d1-blog-server --remote --file=./schema.sql .PHONY: init-db-local init-db-local: diff --git a/_examples/d1-blog-server/README.md b/_examples/d1-blog-server/README.md index e4ce37b4..eb4f27fb 100644 --- a/_examples/d1-blog-server/README.md +++ b/_examples/d1-blog-server/README.md @@ -59,7 +59,7 @@ $ curl 'https://d1-blog-server.syumai.workers.dev/articles' This project requires these tools to be installed globally. * wrangler -* tinygo +* Go 1.24.0 or later ### Commands @@ -70,8 +70,10 @@ make dev # run dev server make build # build Go Wasm binary # production -make init-db # initialize production DB (remove all rows) -make deploy # deploy worker +make create-db # create production DB +# copy binding to wrangler.toml +make init-db # initialize production DB (remove all rows) +make deploy # deploy worker ``` -* Notice: This example uses raw SQL commands to initialize the DB for simplicity, but in general you should use `wrangler d1 migraions` for your application. +* Notice: This example uses raw SQL commands to initialize the DB for simplicity, but in general you should use `wrangler d1 migrations` for your application. diff --git a/_examples/d1-blog-server/main.go b/_examples/d1-blog-server/main.go index abbcaeed..105b4a8e 100644 --- a/_examples/d1-blog-server/main.go +++ b/_examples/d1-blog-server/main.go @@ -11,7 +11,7 @@ import ( ) func main() { - db, err := sql.Open("d1", "BlogDB") + db, err := sql.Open("d1", "DB") if err != nil { log.Fatalf("error opening DB: %s", err.Error()) } diff --git a/_examples/d1-blog-server/wrangler.toml b/_examples/d1-blog-server/wrangler.toml index e3cda000..6f1fc204 100644 --- a/_examples/d1-blog-server/wrangler.toml +++ b/_examples/d1-blog-server/wrangler.toml @@ -4,9 +4,3 @@ compatibility_date = "2024-04-15" [build] command = "make build" - -[[ d1_databases ]] -binding = "BlogDB" -database_name = "d1-blog-server" -database_id = "c6d5e4c0-3134-42fa-834c-812b24fea3cf" -preview_database_id = "BlogDB" diff --git a/_examples/durable-object-counter/Makefile b/_examples/durable-object-counter/Makefile index 019492c2..ec9f8f92 100644 --- a/_examples/durable-object-counter/Makefile +++ b/_examples/durable-object-counter/Makefile @@ -4,8 +4,8 @@ dev: .PHONY: build build: - go run ../../cmd/workers-assets-gen - tinygo build -o ./build/app.wasm -target wasm -no-debug ./... + go run ../../cmd/workers-assets-gen -mode=go + GOOS=js GOARCH=wasm go build -o ./build/app.wasm ./... .PHONY: deploy deploy: diff --git a/_examples/durable-object-counter/README.md b/_examples/durable-object-counter/README.md index a16e490f..c9fe7d54 100644 --- a/_examples/durable-object-counter/README.md +++ b/_examples/durable-object-counter/README.md @@ -21,14 +21,14 @@ After `make deploy` the trigger is `http://durable-object-counter.YOUR-DOMAIN.wo This project requires these tools to be installed globally. * wrangler -* tinygo +* Go 1.24.0 or later ### Commands ``` make dev # run dev server make build # build Go Wasm binary -make deploy # deploy worker +make deploy # deploy worker ``` ## Author diff --git a/_examples/durable-object-counter/main.go b/_examples/durable-object-counter/main.go index c5ccb410..417d89bb 100644 --- a/_examples/durable-object-counter/main.go +++ b/_examples/durable-object-counter/main.go @@ -12,6 +12,10 @@ func main() { workers.Serve(&MyHandler{}) } +func canHaveBody(method string) bool { + return method != "GET" && method != "HEAD" && method != "" +} + type MyHandler struct{} func (_ *MyHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { @@ -26,6 +30,10 @@ func (_ *MyHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { panic(err) } + if !canHaveBody(req.Method) { + req.Body = nil + } + res, err := obj.Fetch(req) if err != nil { panic(err) diff --git a/_examples/durable-object-counter/wrangler.toml b/_examples/durable-object-counter/wrangler.toml index 9116eee0..9b6ac428 100644 --- a/_examples/durable-object-counter/wrangler.toml +++ b/_examples/durable-object-counter/wrangler.toml @@ -13,4 +13,4 @@ bindings = [{name = "COUNTER", class_name = "Counter"}] [[migrations]] tag = "v1" # Should be unique for each entry -new_classes = ["Counter"] \ No newline at end of file +new_sqlite_classes = ["Counter"] \ No newline at end of file diff --git a/_examples/env/Makefile b/_examples/env/Makefile index 019492c2..ec9f8f92 100644 --- a/_examples/env/Makefile +++ b/_examples/env/Makefile @@ -4,8 +4,8 @@ dev: .PHONY: build build: - go run ../../cmd/workers-assets-gen - tinygo build -o ./build/app.wasm -target wasm -no-debug ./... + go run ../../cmd/workers-assets-gen -mode=go + GOOS=js GOARCH=wasm go build -o ./build/app.wasm ./... .PHONY: deploy deploy: diff --git a/_examples/env/README.md b/_examples/env/README.md index ad79b973..280a0379 100644 --- a/_examples/env/README.md +++ b/_examples/env/README.md @@ -13,12 +13,12 @@ This project requires these tools to be installed globally. * wrangler -* tinygo +* Go 1.24.0 or later ### Commands ``` make dev # run dev server make build # build Go Wasm binary -make deploy # deploy worker +make deploy # deploy worker ``` diff --git a/_examples/fetch-event/Makefile b/_examples/fetch-event/Makefile index 019492c2..ec9f8f92 100644 --- a/_examples/fetch-event/Makefile +++ b/_examples/fetch-event/Makefile @@ -4,8 +4,8 @@ dev: .PHONY: build build: - go run ../../cmd/workers-assets-gen - tinygo build -o ./build/app.wasm -target wasm -no-debug ./... + go run ../../cmd/workers-assets-gen -mode=go + GOOS=js GOARCH=wasm go build -o ./build/app.wasm ./... .PHONY: deploy deploy: diff --git a/_examples/fetch-event/README.md b/_examples/fetch-event/README.md index f20fd692..32c13a6a 100644 --- a/_examples/fetch-event/README.md +++ b/_examples/fetch-event/README.md @@ -37,12 +37,12 @@ The workers is executed if the URL matches `sub.example.com/*`. This project requires these tools to be installed globally. * wrangler -* tinygo +* Go 1.24.0 or later #### Commands ``` make dev # run dev server make build # build Go Wasm binary -make deploy # deploy worker +make deploy # deploy worker ``` \ No newline at end of file diff --git a/_examples/fetch-event/wrangler.toml b/_examples/fetch-event/wrangler.toml index 0d0e6da6..03d073ef 100644 --- a/_examples/fetch-event/wrangler.toml +++ b/_examples/fetch-event/wrangler.toml @@ -2,9 +2,10 @@ name = "fetch-event" main = "./build/worker.mjs" compatibility_date = "2023-02-24" -routes = [ - { pattern = "example.com/*", zone_name = "example.com" } -] +# setup route and uncomment +# routes = [ +# { pattern = "example.com/*", zone_name = "example.com" } +# ] [build] command = "make build" diff --git a/_examples/fetch/Makefile b/_examples/fetch/Makefile index 019492c2..ec9f8f92 100644 --- a/_examples/fetch/Makefile +++ b/_examples/fetch/Makefile @@ -4,8 +4,8 @@ dev: .PHONY: build build: - go run ../../cmd/workers-assets-gen - tinygo build -o ./build/app.wasm -target wasm -no-debug ./... + go run ../../cmd/workers-assets-gen -mode=go + GOOS=js GOARCH=wasm go build -o ./build/app.wasm ./... .PHONY: deploy deploy: diff --git a/_examples/fetch/README.md b/_examples/fetch/README.md index cd532e5b..6275cd44 100644 --- a/_examples/fetch/README.md +++ b/_examples/fetch/README.md @@ -10,12 +10,11 @@ This project requires these tools to be installed globally. * wrangler -* tinygo - +* Go 1.24.0 or later ### Commands ``` make dev # run dev server make build # build Go Wasm binary -make deploy # deploy worker +make deploy # deploy worker ``` \ No newline at end of file diff --git a/_examples/incoming/Makefile b/_examples/incoming/Makefile index 019492c2..ec9f8f92 100644 --- a/_examples/incoming/Makefile +++ b/_examples/incoming/Makefile @@ -4,8 +4,8 @@ dev: .PHONY: build build: - go run ../../cmd/workers-assets-gen - tinygo build -o ./build/app.wasm -target wasm -no-debug ./... + go run ../../cmd/workers-assets-gen -mode=go + GOOS=js GOARCH=wasm go build -o ./build/app.wasm ./... .PHONY: deploy deploy: diff --git a/_examples/kv-counter/Makefile b/_examples/kv-counter/Makefile index 019492c2..95235a39 100644 --- a/_examples/kv-counter/Makefile +++ b/_examples/kv-counter/Makefile @@ -4,8 +4,12 @@ dev: .PHONY: build build: - go run ../../cmd/workers-assets-gen - tinygo build -o ./build/app.wasm -target wasm -no-debug ./... + go run ../../cmd/workers-assets-gen -mode=go + GOOS=js GOARCH=wasm go build -o ./build/app.wasm ./... + +.PHONY: create-kv-namespace +create-kv-namespace: + wrangler kv namespace create COUNTER .PHONY: deploy deploy: diff --git a/_examples/kv-counter/README.md b/_examples/kv-counter/README.md index 1ea90a0a..76a107d0 100644 --- a/_examples/kv-counter/README.md +++ b/_examples/kv-counter/README.md @@ -13,12 +13,13 @@ This project requires these tools to be installed globally. * wrangler -* tinygo +* Go 1.24.0 or later ### Commands ``` -make dev # run dev server -make build # build Go Wasm binary -make deploy # deploy worker +make dev # run dev server +make build # build Go Wasm binary +make create-kv-namespace # creates a kv namespace - add binding to wrangler.toml before deploy +make deploy # deploy worker ``` diff --git a/_examples/kv-counter/wrangler.toml b/_examples/kv-counter/wrangler.toml index 23b29adb..e2d5cb69 100644 --- a/_examples/kv-counter/wrangler.toml +++ b/_examples/kv-counter/wrangler.toml @@ -5,10 +5,5 @@ compatibility_flags = [ "streams_enable_constructors" ] -[[kv_namespaces]] -binding = "COUNTER" -id = "fe0ef36853f04fe986c1ade5271ea6a4" -preview_id = "916f05d37f4741e0a19aa3d0bd4d282e" - [build] command = "make build" diff --git a/_examples/multiple-handlers/Makefile b/_examples/multiple-handlers/Makefile index eaa93565..0a705f23 100644 --- a/_examples/multiple-handlers/Makefile +++ b/_examples/multiple-handlers/Makefile @@ -4,8 +4,8 @@ dev: .PHONY: build build: - go run ../../cmd/workers-assets-gen - tinygo build -o ./build/app.wasm -target wasm -no-debug ./... + go run ../../cmd/workers-assets-gen -mode=go + GOOS=js GOARCH=wasm go build -o ./build/app.wasm ./... .PHONY: deploy deploy: diff --git a/_examples/multiple-handlers/README.md b/_examples/multiple-handlers/README.md index 768d3350..9476a1dc 100644 --- a/_examples/multiple-handlers/README.md +++ b/_examples/multiple-handlers/README.md @@ -9,14 +9,14 @@ This project requires these tools to be installed globally. * wrangler -* tinygo +* Go 1.24.0 or later ### Commands ``` make dev # run dev server make build # build Go Wasm binary -make deploy # deploy worker +make deploy # deploy worker ``` #### Testing cron schedule diff --git a/_examples/multiple-handlers/wrangler.toml b/_examples/multiple-handlers/wrangler.toml index c0dc4c18..2a7b7120 100644 --- a/_examples/multiple-handlers/wrangler.toml +++ b/_examples/multiple-handlers/wrangler.toml @@ -1,7 +1,6 @@ name = "multiple-handlers" main = "./build/worker.mjs" compatibility_date = "2023-02-24" -workers_dev = false [triggers] crons = ["* * * * *"] diff --git a/_examples/pages-functions/Makefile b/_examples/pages-functions/Makefile index 93be154a..720722f4 100644 --- a/_examples/pages-functions/Makefile +++ b/_examples/pages-functions/Makefile @@ -4,8 +4,8 @@ dev: .PHONY: build build: - go run ../../cmd/workers-assets-gen - tinygo build -o ./build/app.wasm -target wasm -no-debug ./... + go run ../../cmd/workers-assets-gen -mode=go + GOOS=js GOARCH=wasm go build -o ./build/app.wasm ./... .PHONY: deploy deploy: diff --git a/_examples/pages-functions/README.md b/_examples/pages-functions/README.md index 04aa5750..eb2f976a 100644 --- a/_examples/pages-functions/README.md +++ b/_examples/pages-functions/README.md @@ -13,12 +13,12 @@ This project requires these tools to be installed globally. * wrangler -* tinygo +* Go 1.24.0 or later ### Commands ``` make build # build Go Wasm binary make dev # run dev server -make deploy # deploy worker +make deploy # deploy worker ``` diff --git a/_examples/pages-functions/wrangler.toml b/_examples/pages-functions/wrangler.toml index 29ea062e..0d436677 100644 --- a/_examples/pages-functions/wrangler.toml +++ b/_examples/pages-functions/wrangler.toml @@ -1,2 +1,6 @@ name = "pages-functions" +main = "./build/worker.mjs" compatibility_date = "2023-04-30" + +[build] +command = "make build" \ No newline at end of file diff --git a/_examples/queues/Makefile b/_examples/queues/Makefile index 019492c2..547c9e35 100644 --- a/_examples/queues/Makefile +++ b/_examples/queues/Makefile @@ -4,8 +4,12 @@ dev: .PHONY: build build: - go run ../../cmd/workers-assets-gen - tinygo build -o ./build/app.wasm -target wasm -no-debug ./... + go run ../../cmd/workers-assets-gen -mode=go + GOOS=js GOARCH=wasm go build -o ./build/app.wasm ./... + +.PHONY: create-queue +create-queue: + wrangler queues create my-queue .PHONY: deploy deploy: diff --git a/_examples/queues/README.md b/_examples/queues/README.md index 9d01dd1d..fb920460 100644 --- a/_examples/queues/README.md +++ b/_examples/queues/README.md @@ -9,14 +9,15 @@ An example of using Cloudflare Workers that interact with [Cloudflare Queues](ht This project requires these tools to be installed globally. * wrangler -* tinygo +* Go 1.24.0 or later ### Supported commands ``` -make dev # run dev server -make build # build Go Wasm binary -make deploy # deploy worker +make dev # run dev server +make build # build Go Wasm binary +make create-queue # creates the queue +make deploy # deploy worker ``` ### Interacting with the local queue diff --git a/_examples/r2-image-server/Makefile b/_examples/r2-image-server/Makefile index 019492c2..ef502ca1 100644 --- a/_examples/r2-image-server/Makefile +++ b/_examples/r2-image-server/Makefile @@ -4,8 +4,12 @@ dev: .PHONY: build build: - go run ../../cmd/workers-assets-gen - tinygo build -o ./build/app.wasm -target wasm -no-debug ./... + go run ../../cmd/workers-assets-gen -mode=go + GOOS=js GOARCH=wasm go build -o ./build/app.wasm . + +.PHONY: create-bucket +create-bucket: + wrangler r2 bucket create r2-image-viewer .PHONY: deploy deploy: diff --git a/_examples/r2-image-server/README.md b/_examples/r2-image-server/README.md index 20b54591..a95a7ef4 100644 --- a/_examples/r2-image-server/README.md +++ b/_examples/r2-image-server/README.md @@ -26,12 +26,13 @@ This project requires these tools to be installed globally. * wrangler -* tinygo +* Go 1.24.0 or later ### Commands ``` -make dev # run dev server -make build # build Go Wasm binary -make deploy # deploy worker +make dev # run dev server +make build # build Go Wasm binary +make create-bucket # create r2 bucket +make deploy # deploy worker ``` diff --git a/_examples/r2-image-viewer/Makefile b/_examples/r2-image-viewer/Makefile index 019492c2..cff2000f 100644 --- a/_examples/r2-image-viewer/Makefile +++ b/_examples/r2-image-viewer/Makefile @@ -4,8 +4,12 @@ dev: .PHONY: build build: - go run ../../cmd/workers-assets-gen - tinygo build -o ./build/app.wasm -target wasm -no-debug ./... + go run ../../cmd/workers-assets-gen -mode=go + GOOS=js GOARCH=wasm go build -o ./build/app.wasm ./... + +.PHONY: create-bucket +create-bucket: + wrangler r2 bucket create r2-image-viewer .PHONY: deploy deploy: diff --git a/_examples/r2-image-viewer/README.md b/_examples/r2-image-viewer/README.md index 5d483eb0..4e1f5d76 100644 --- a/_examples/r2-image-viewer/README.md +++ b/_examples/r2-image-viewer/README.md @@ -1,7 +1,7 @@ # r2-image-viewer-tinygo * An example server which returns image from Cloudflare R2. -* This server is implemented in Go and compiled with tinygo. +* This server is implemented in Go. ## Example @@ -14,12 +14,13 @@ This project requires these tools to be installed globally. * wrangler -* tinygo +* Go 1.24.0 or later ### Commands ``` -make dev # run dev server -make build # build Go Wasm binary -make deploy # deploy worker +make dev # run dev server +make build # build Go Wasm binary +make create-bucket # create r2 bucket +make deploy # deploy worker ``` diff --git a/_examples/service-bindings/Makefile b/_examples/service-bindings/Makefile index 019492c2..ec9f8f92 100644 --- a/_examples/service-bindings/Makefile +++ b/_examples/service-bindings/Makefile @@ -4,8 +4,8 @@ dev: .PHONY: build build: - go run ../../cmd/workers-assets-gen - tinygo build -o ./build/app.wasm -target wasm -no-debug ./... + go run ../../cmd/workers-assets-gen -mode=go + GOOS=js GOARCH=wasm go build -o ./build/app.wasm ./... .PHONY: deploy deploy: diff --git a/_examples/service-bindings/README.md b/_examples/service-bindings/README.md index a905a0c3..94f4e487 100644 --- a/_examples/service-bindings/README.md +++ b/_examples/service-bindings/README.md @@ -10,7 +10,7 @@ This project requires these tools to be installed globally. * wrangler -* tinygo +* Go 1.24.0 or later ### Deploy Steps @@ -24,7 +24,7 @@ This project requires these tools to be installed globally. 3. Deploy this example. ``` make build # build Go Wasm binary - make deploy # deploy worker + make deploy # deploy worker ``` ## Documents diff --git a/_examples/simple-json-server/Makefile b/_examples/simple-json-server/Makefile index 8ac4d8a7..ec9f8f92 100644 --- a/_examples/simple-json-server/Makefile +++ b/_examples/simple-json-server/Makefile @@ -4,8 +4,8 @@ dev: .PHONY: build build: - go run ../../cmd/workers-assets-gen - tinygo build -o ./build/app.wasm -target wasm -no-debug ./main.go + go run ../../cmd/workers-assets-gen -mode=go + GOOS=js GOARCH=wasm go build -o ./build/app.wasm ./... .PHONY: deploy deploy: diff --git a/_examples/simple-json-server/README.md b/_examples/simple-json-server/README.md index 2e5ca7e9..7e91887f 100644 --- a/_examples/simple-json-server/README.md +++ b/_examples/simple-json-server/README.md @@ -31,12 +31,12 @@ curl --location --request POST 'https://simple-json-server.syumai.workers.dev/he This project requires these tools to be installed globally. * wrangler -* tinygo +* Go 1.24.0 or later ### Commands ``` make dev # run dev server make build # build Go Wasm binary -make deploy # deploy worker +make deploy # deploy worker ``` diff --git a/_examples/stream-large-file/Makefile b/_examples/stream-large-file/Makefile index 019492c2..ec9f8f92 100644 --- a/_examples/stream-large-file/Makefile +++ b/_examples/stream-large-file/Makefile @@ -4,8 +4,8 @@ dev: .PHONY: build build: - go run ../../cmd/workers-assets-gen - tinygo build -o ./build/app.wasm -target wasm -no-debug ./... + go run ../../cmd/workers-assets-gen -mode=go + GOOS=js GOARCH=wasm go build -o ./build/app.wasm ./... .PHONY: deploy deploy: diff --git a/_examples/stream-large-file/README.md b/_examples/stream-large-file/README.md index cb751db8..0051ad97 100644 --- a/_examples/stream-large-file/README.md +++ b/_examples/stream-large-file/README.md @@ -7,12 +7,12 @@ This project requires these tools to be installed globally. * wrangler -* tinygo +* Go 1.24.0 or later ### Commands ``` make dev # run dev server make build # build Go Wasm binary -make deploy # deploy worker +make deploy # deploy worker ``` \ No newline at end of file