-
Notifications
You must be signed in to change notification settings - Fork 927
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question]tinygo build wasm error when use protobuf #1879
Comments
hello.go
i tried to use json like above, but still got an error: so, if i can use any other way to serialize a struct ? |
I met those compiled errors as the same with yours If you solve this problem, Please tell me. we can solve this problem jointly. |
Some of these issues are fixed in the latest release. Can you try again with the latest release? |
Hi, I need your help, My Env : get a runtime error: Whether My go version is too low. |
@aykevl thank you for you reply. as @dengliangjun said, after i upgrade tinygo to 1.18.0 when i used
when i used
the difference is for protobuf, the error is happened at compiled time, but for json, the error is happened at runtime 😂 |
the same errors as you, me too!
I want to solve/contribute this issue. Whether there is anyone else can direct me.
来自skycto.com企业邮箱------------------------------------------------------------------
***@***.***>
日 期:2021年05月20日 11:10:12
***@***.***>
***@***.***>; ***@***.***>
主 题:Re: [tinygo-org/tinygo] [Question]tinygo build wasm error when use protobuf (#1879)
@aykevl thank you for you reply.
as @deadprogram said, after i upgrade tinygo to 1.18.0
when i used protobuf to serialize a struct, i got an error:
github.com/golang/protobuf/proto/clone.go:222:20: AppendSlice not declared by package reflect
when i used json to serialize a struct, i got an another error:
panic: unimplemented: (reflect.Type).Name()
the difference is for protobuf, the error is happened at compiled time, but for json, the error is happened at runtime 😂
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Well I had the same problem, i highly suggest to use go go proto instead. Make sure you remove extra methods from generated .pb.go files and just keep marshal and unmarshal methods |
Yes, I'm aware of this issue. It is something that I want to fix in the reflect package. Unfortunately there is no easy fix. |
This should be fixed with this PR: #1902 |
|
@aykevl thank you for your attention about this issue. I have tried to compile the latest It's my bad that I didn't describe the problem clearly before, so let me redo this. use tinyGo
use tinyGo
PR: #1902 really solve the I also tried to use could you share your code? |
Hi @zhenjunMa Here is one of our protos
the generated gogo file has many functions just keep these
and the main struct which is
in my case. for generating proto.bp.go files use this command |
Here is my script to aggressively strip lines https://gist.github.com/alanpoon/541ceea2129412b5a5ae046ad90fccd6 |
I am working on refactoring the reflect package to be more powerful. This is still a work in progress, but once completed I think it will be feasible to implement the remaining features necessary for protobuf. |
Is this (the reflect package work and the protobuf support) still WIP? I'd love for the proxy-wasm-go issue to move forward but it's depending on this ticket. |
Using tinygo
Which was strange as func NewAt(typ Type, p unsafe.Pointer) Value {
panic("unimplemented: reflect.New()")
} And looking at the protobuf-go code you can find a call to it here: https://github.com/protocolbuffers/protobuf-go/blob/master/internal/impl/pointer_unsafe.go#L78 |
Question
when i use struct compiled by protobuf, and use tinygo build to a wasm file, i got an error.
How to reproduce
model.proto
build command
protoc -I. --go_out=. model.proto
hello.go
build command:
tinygo build -o wasm.wasm -target wasm ./hello.go
error:

i have uploaded the total project: https://github.com/zhenjunMa/TinyGoProtoBuf
any idea about how to solve this? or tinygo can not support protobuf now.
The text was updated successfully, but these errors were encountered: