Skip to content

Commit

Permalink
Merge pull request #2977 from itowlson/tinygo-global-init-fixes
Browse files Browse the repository at this point in the history
Update TinyGo templates to address static init problems
  • Loading branch information
lann authored Jan 13, 2025
2 parents 511bf55 + ee541b8 commit 771282e
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ FROM mcr.microsoft.com/vscode/devcontainers/rust:0-${VARIANT}
# && apt-get -y install --no-install-recommends <your-package-list-here>

# 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
Expand Down
4 changes: 2 additions & 2 deletions .github/actions/spin-ci-dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ inputs:
type: bool
golang-version:
description: 'golang version to setup'
default: '1.20'
default: '1.22'
required: false
type: string

Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,10 @@ 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.27.0'
tinygo-version: '0.35.0'
- uses: actions/setup-node@v3
with:
node-version: '20.x'
Expand Down
2 changes: 1 addition & 1 deletion templates/http-go/content/go.mod
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 0 additions & 2 deletions templates/http-go/content/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,3 @@ func init() {
fmt.Fprintln(w, "Hello Fermyon!")
})
}

func main() {}
2 changes: 1 addition & 1 deletion templates/http-go/content/spin.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
2 changes: 1 addition & 1 deletion templates/http-go/metadata/snippets/component.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
2 changes: 1 addition & 1 deletion templates/redis-go/content/go.mod
Original file line number Diff line number Diff line change
@@ -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
3 changes: 0 additions & 3 deletions templates/redis-go/content/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,3 @@ func init() {
return nil
})
}

// main functiion must be included for the compiler but is not executed.
func main() {}

0 comments on commit 771282e

Please sign in to comment.