From fffd1262d549629580f777af440f217a59499e1e Mon Sep 17 00:00:00 2001 From: itowlson Date: Mon, 13 Jan 2025 12:26:29 +1300 Subject: [PATCH 1/3] Update TinyGo templates to address static init problems E.g. this should fix static logging objects not being ready, os.Environ(), etc. Signed-off-by: itowlson --- .github/actions/spin-ci-dependencies/action.yml | 2 +- .github/workflows/build.yml | 2 +- templates/http-go/content/spin.toml | 2 +- templates/http-go/metadata/snippets/component.txt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/actions/spin-ci-dependencies/action.yml b/.github/actions/spin-ci-dependencies/action.yml index b8a4bfee51..8737a79eef 100644 --- a/.github/actions/spin-ci-dependencies/action.yml +++ b/.github/actions/spin-ci-dependencies/action.yml @@ -68,7 +68,7 @@ inputs: type: bool tinygo-version: description: 'tinygo version to setup' - default: 'v0.27.0' + default: 'v0.35.0' required: false type: string diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 022fbfd31b..3a9c4630da 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -203,7 +203,7 @@ jobs: go-version: '1.20.1' - uses: acifani/setup-tinygo@v2 with: - tinygo-version: '0.27.0' + tinygo-version: '0.35.0' - uses: actions/setup-node@v3 with: node-version: '20.x' diff --git a/templates/http-go/content/spin.toml b/templates/http-go/content/spin.toml index 2d9e427242..326a5ddc81 100644 --- a/templates/http-go/content/spin.toml +++ b/templates/http-go/content/spin.toml @@ -14,5 +14,5 @@ component = "{{project-name | kebab_case}}" source = "main.wasm" allowed_outbound_hosts = [] [component.{{project-name | kebab_case}}.build] -command = "tinygo build -target=wasi -gc=leaking -no-debug -o main.wasm main.go" +command = "tinygo build -target=wasip1 -gc=leaking -scheduler=none -buildmode=c-shared -no-debug -o main.wasm ." watch = ["**/*.go", "go.mod"] diff --git a/templates/http-go/metadata/snippets/component.txt b/templates/http-go/metadata/snippets/component.txt index d466c9b431..4fbb89ba25 100644 --- a/templates/http-go/metadata/snippets/component.txt +++ b/templates/http-go/metadata/snippets/component.txt @@ -6,6 +6,6 @@ component = "{{project-name | kebab_case}}" source = "{{ output-path }}/main.wasm" allowed_outbound_hosts = [] [component.{{project-name | kebab_case}}.build] -command = "tinygo build -target=wasi -gc=leaking -no-debug -o main.wasm main.go" +command = "tinygo build -target=wasip1 -gc=leaking -scheduler=none -buildmode=c-shared -no-debug -o main.wasm ." workdir = "{{ output-path }}" watch = ["**/*.go", "go.mod"] From 2589812e83d01ba33b04c512b34a23ae9e4dd19a Mon Sep 17 00:00:00 2001 From: itowlson Date: Mon, 13 Jan 2025 13:09:34 +1300 Subject: [PATCH 2/3] Bump Go to 1.22 for wasip1 Signed-off-by: itowlson --- .devcontainer/Dockerfile | 4 ++-- .github/actions/spin-ci-dependencies/action.yml | 2 +- .github/workflows/build.yml | 2 +- templates/http-go/content/go.mod | 2 +- templates/redis-go/content/go.mod | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index b8b56fb80e..29b1347029 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -9,12 +9,12 @@ FROM mcr.microsoft.com/vscode/devcontainers/rust:0-${VARIANT} # && apt-get -y install --no-install-recommends # Go installation, see https://go.dev/doc/install -ARG GO_URL="https://go.dev/dl/go1.20.1.linux-amd64.tar.gz" +ARG GO_URL="https://go.dev/dl/go1.22.0.linux-amd64.tar.gz" RUN curl -sL "$GO_URL" | tar -xzf - -C /usr/local ENV PATH "$PATH:/usr/local/go/bin" # TinyGo installation, see https://tinygo.org/getting-started/install/linux/ for instructions -ARG TINYGO_URL="https://github.com/tinygo-org/tinygo/releases/download/v0.27.0/tinygo_0.27.0_amd64.deb" +ARG TINYGO_URL="https://github.com/tinygo-org/tinygo/releases/download/v0.35.0/tinygo_0.35.0_amd64.deb" RUN curl -sL "$TINYGO_URL" -o tinygo_amd64.deb && dpkg -i tinygo_amd64.deb && rm tinygo_amd64.deb # Install the gopls Go Language Server, see https://github.com/golang/tools/tree/master/gopls diff --git a/.github/actions/spin-ci-dependencies/action.yml b/.github/actions/spin-ci-dependencies/action.yml index 8737a79eef..e507a73e62 100644 --- a/.github/actions/spin-ci-dependencies/action.yml +++ b/.github/actions/spin-ci-dependencies/action.yml @@ -46,7 +46,7 @@ inputs: type: bool golang-version: description: 'golang version to setup' - default: '1.20' + default: '1.22' required: false type: string diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3a9c4630da..10a73e43b1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -200,7 +200,7 @@ jobs: - uses: goto-bus-stop/setup-zig@v2 - uses: actions/setup-go@v4 with: - go-version: '1.20.1' + go-version: '1.22' - uses: acifani/setup-tinygo@v2 with: tinygo-version: '0.35.0' diff --git a/templates/http-go/content/go.mod b/templates/http-go/content/go.mod index df6c14edc7..b395dc51e4 100644 --- a/templates/http-go/content/go.mod +++ b/templates/http-go/content/go.mod @@ -1,6 +1,6 @@ module github.com/{{project-name | snake_case}} -go 1.20 +go 1.22 require github.com/fermyon/spin/sdk/go/v2 v2.2.0 diff --git a/templates/redis-go/content/go.mod b/templates/redis-go/content/go.mod index 11b1d814e5..014c36d49b 100644 --- a/templates/redis-go/content/go.mod +++ b/templates/redis-go/content/go.mod @@ -1,5 +1,5 @@ module github.com/{{project-name | snake_case}} -go 1.20 +go 1.22 require github.com/fermyon/spin/sdk/go/v2 v2.2.0 From ee541b8368f8297defbcf62b9650f06b5acb03b4 Mon Sep 17 00:00:00 2001 From: itowlson Date: Mon, 13 Jan 2025 14:22:02 +1300 Subject: [PATCH 3/3] TinyGo 0.35 no longer requires `main` for components Signed-off-by: itowlson --- templates/http-go/content/main.go | 2 -- templates/redis-go/content/main.go | 3 --- 2 files changed, 5 deletions(-) diff --git a/templates/http-go/content/main.go b/templates/http-go/content/main.go index 93d63a894e..ad1064bab0 100644 --- a/templates/http-go/content/main.go +++ b/templates/http-go/content/main.go @@ -13,5 +13,3 @@ func init() { fmt.Fprintln(w, "Hello Fermyon!") }) } - -func main() {} diff --git a/templates/redis-go/content/main.go b/templates/redis-go/content/main.go index 5258d507f1..cf7ce8137d 100644 --- a/templates/redis-go/content/main.go +++ b/templates/redis-go/content/main.go @@ -14,6 +14,3 @@ func init() { return nil }) } - -// main functiion must be included for the compiler but is not executed. -func main() {}