Skip to content

Resolve the build error encountered when using TinyGo.#1052

Closed
cxjava wants to merge 1 commit into
maxence-charriere:masterfrom
cxjava:patch-1
Closed

Resolve the build error encountered when using TinyGo.#1052
cxjava wants to merge 1 commit into
maxence-charriere:masterfrom
cxjava:patch-1

Conversation

@cxjava
Copy link
Copy Markdown
Contributor

@cxjava cxjava commented Mar 12, 2025

When attempting to build the application using TinyGo, an error occurs:

tinygo build -target wasm -o web/app.wasm -no-debug -panic=trap
# github.com/maxence-charriere/go-app/v10/pkg/app
../../../go/pkg/mod/github.com/maxence-charriere/go-app/v10@v10.1.1/pkg/app/node.go:788:13: v.Equal undefined (type reflect.Value has no field or method Equal)
../../../go/pkg/mod/github.com/maxence-charriere/go-app/v10@v10.1.1/pkg/app/node.go:793:14: v.Equal undefined (type reflect.Value has no field or method Equal)

The problem was that TinyGo's implementation of the reflect package is more limited than standard Go's. The Equal method that exists on reflect.Value in standard Go is not available in TinyGo.

  1. Handle each primitive type explicitly using the appropriate getter methods (String(), Bool(), Int(), etc.)
  2. For the time.Time case, extract the actual values and use the Equal method on the time.Time type itself
  3. Keep the reflect.DeepEqual fallback for other types

@mlctrez
Copy link
Copy Markdown
Contributor

mlctrez commented Mar 12, 2025

Is this still an issue when using tinygo version 0.36.0 ?

This PR tinygo-org/tinygo#4771 last week added the method Value.Equal()

A sample go-app application compiles fine with

go version go1.23.7 linux/amd64
tinygo version 0.36.0 linux/amd64 (using go version go1.23.7 and LLVM version 19.1.2)

@cxjava
Copy link
Copy Markdown
Contributor Author

cxjava commented Mar 13, 2025

Hi @mlctrez
Thank you for your kind correction! After upgrading TinyGo from version 0.35 to 0.36, the build process completed successfully without any errors.
I will close this PR.

tinygo version
tinygo version 0.36.0 darwin/amd64 (using go version go1.23.2 and LLVM version 19.1.2)

@cxjava cxjava closed this Mar 13, 2025
@cxjava cxjava reopened this Mar 20, 2025
@cxjava
Copy link
Copy Markdown
Contributor Author

cxjava commented Mar 20, 2025

I still need this fix, because of I have app which build by tinygo, have below issue:

main-006f0f46:0xbea3 Uncaught (in promise) RuntimeError: unreachable
    at main.internal/task.Pause (main-006f0f46:0xbea3)
    at main.runtime.chanSelect (main-006f0f46:0x3ce8c)
    at main.runtime.run$1$gowrapper (main-006f0f46:0x1d11f)
    at main.runtime.scheduler (main-006f0f46:0xd07b)
    at main._start.command_export (main-006f0f46:0x10ff1b)
    at global.Go.run (wasm_exec.js:1:5947)
    at goappInitWebAssembly (app.js:1:3105)
$internal/task.Pause @ main-006f0f46:0xbea3
$runtime.chanSelect @ main-006f0f46:0x3ce8c
$runtime.run$1$gowrapper @ main-006f0f46:0x1d11f
$runtime.scheduler @ main-006f0f46:0xd07b
$_start.command_export @ main-006f0f46:0x10ff1b
run @ wasm_exec.js:1
goappInitWebAssembly @ app.js:1
await in goappInitWebAssembly
(anonymous) @ app.js:1Understand this errorAI
wasm_exec.js:1 Uncaught RuntimeError: null function or function signature mismatch
    at main.runtime.scheduler (main-006f0f46:0xd07b)
    at main.resume.command_export (main-006f0f46:0x10fcf7)
    at global.Go._resume (wasm_exec.js:1:6141)
    at wasm_exec.js:1:6330
    at app.js:1:971
$runtime.scheduler @ main-006f0f46:0xd07b
$resume.command_export @ main-006f0f46:0x10fcf7
_resume @ wasm_exec.js:1
(anonymous) @ wasm_exec.js:1
(anonymous) @ app.js:1Understand this errorAI
localhost/:1 Banner not shown: beforeinstallpromptevent.preventDefault() called. The page must call beforeinstallpromptevent.prompt() to show the banner.
wasm_exec.js:1 Uncaught RuntimeError: memory access out of bounds
    at main.internal/task.start (main-006f0f46:0xc069)
    at main.resume.command_export (main-006f0f46:0x10fceb)
    at global.Go._resume (wasm_exec.js:1:6141)
    at wasm_exec.js:1:6330

tinygo version with error:

tinygo version 0.37.0 darwin/amd64 (using go version go1.24.1 and LLVM version 19.1.2)

it works fine with below tinygo version:

tinygo version 0.35.0 darwin/amd64 (using go version go1.23.7 and LLVM version 18.1.2)

@oderwat
Copy link
Copy Markdown
Contributor

oderwat commented Mar 20, 2025

I think you should report this in the TinyGo repository.

@cxjava cxjava closed this Sep 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants