From 8546b90d48ffe54af07b270384d0d563db8ebe63 Mon Sep 17 00:00:00 2001 From: syumai Date: Sat, 9 Sep 2023 21:47:23 +0900 Subject: [PATCH 1/2] add go.mod to templates --- _templates/cloudflare/worker-go/go.mod | 3 +++ _templates/cloudflare/worker-tinygo/go.mod | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 _templates/cloudflare/worker-go/go.mod create mode 100644 _templates/cloudflare/worker-tinygo/go.mod diff --git a/_templates/cloudflare/worker-go/go.mod b/_templates/cloudflare/worker-go/go.mod new file mode 100644 index 0000000..762980b --- /dev/null +++ b/_templates/cloudflare/worker-go/go.mod @@ -0,0 +1,3 @@ +module github.com/syumai/workers/_templates/cloudflare/worker-go + +go 1.21.1 diff --git a/_templates/cloudflare/worker-tinygo/go.mod b/_templates/cloudflare/worker-tinygo/go.mod new file mode 100644 index 0000000..d8848fb --- /dev/null +++ b/_templates/cloudflare/worker-tinygo/go.mod @@ -0,0 +1,3 @@ +module github.com/syumai/workers/_templates/cloudflare/worker-tinygo + +go 1.21.1 From 146ccd1d7e5b6c4bde97ddd1a2fa02d99d109b5c Mon Sep 17 00:00:00 2001 From: syumai Date: Sat, 9 Sep 2023 22:17:13 +0900 Subject: [PATCH 2/2] replace initialization command of templates to gonew --- _templates/cloudflare/pages-tinygo/README.md | 12 ++++++++++-- _templates/cloudflare/pages-tinygo/go.mod | 2 +- _templates/cloudflare/worker-go/README.md | 14 ++++++++++++-- _templates/cloudflare/worker-tinygo/README.md | 12 ++++++++++-- 4 files changed, 33 insertions(+), 7 deletions(-) diff --git a/_templates/cloudflare/pages-tinygo/README.md b/_templates/cloudflare/pages-tinygo/README.md index 73de321..90d9b15 100644 --- a/_templates/cloudflare/pages-tinygo/README.md +++ b/_templates/cloudflare/pages-tinygo/README.md @@ -16,10 +16,18 @@ ## Getting Started +* If not already installed, please install the [gonew](https://pkg.go.dev/golang.org/x/tools/cmd/gonew) command. + ```console -wrangler generate my-app syumai/workers/_templates/cloudflare/pages-tinygo +go install golang.org/x/tools/cmd/gonew@latest +``` + +* Create a new project using this template. + - Second argument passed to `gonew` is a module path of your new app. + +```console +gonew github.com/syumai/workers/_templates/cloudflare/pages-tinygo your.module/my-app # e.g. github.com/syumai/my-app cd my-app -go mod init go mod tidy make dev # start running dev server curl http://localhost:8787/api/hello # outputs "Hello, Pages Functions!" diff --git a/_templates/cloudflare/pages-tinygo/go.mod b/_templates/cloudflare/pages-tinygo/go.mod index 35458cc..f6d3c4f 100644 --- a/_templates/cloudflare/pages-tinygo/go.mod +++ b/_templates/cloudflare/pages-tinygo/go.mod @@ -1,4 +1,4 @@ -module github.com/syumai/workers/_examples/pages-functions +module github.com/syumai/workers/_examples/pages-tinygo go 1.18 diff --git a/_templates/cloudflare/worker-go/README.md b/_templates/cloudflare/worker-go/README.md index bb95224..c19357a 100644 --- a/_templates/cloudflare/worker-go/README.md +++ b/_templates/cloudflare/worker-go/README.md @@ -21,10 +21,20 @@ ## Getting Started +## Getting Started + +* If not already installed, please install the [gonew](https://pkg.go.dev/golang.org/x/tools/cmd/gonew) command. + ```console -wrangler generate my-app syumai/workers/_templates/cloudflare/worker-go +go install golang.org/x/tools/cmd/gonew@latest +``` + +* Create a new project using this template. + - Second argument passed to `gonew` is a module path of your new app. + +```console +gonew github.com/syumai/workers/_templates/cloudflare/worker-go your.module/my-app # e.g. github.com/syumai/my-app cd my-app -go mod init go mod tidy make dev # start running dev server curl http://localhost:8787/hello # outputs "Hello!" diff --git a/_templates/cloudflare/worker-tinygo/README.md b/_templates/cloudflare/worker-tinygo/README.md index 0333a2b..f7ca25d 100644 --- a/_templates/cloudflare/worker-tinygo/README.md +++ b/_templates/cloudflare/worker-tinygo/README.md @@ -16,10 +16,18 @@ ## Getting Started +* If not already installed, please install the [gonew](https://pkg.go.dev/golang.org/x/tools/cmd/gonew) command. + ```console -wrangler generate my-app syumai/workers/_templates/cloudflare/worker-tinygo +go install golang.org/x/tools/cmd/gonew@latest +``` + +* Create a new project using this template. + - Second argument passed to `gonew` is a module path of your new app. + +```console +gonew github.com/syumai/workers/_templates/cloudflare/worker-tinygo your.module/my-app # e.g. github.com/syumai/my-app cd my-app -go mod init go mod tidy make dev # start running dev server curl http://localhost:8787/hello # outputs "Hello!"