Skip to content

Using emptypb in .proto results in reflection issue with tinygo #76

@amlwwalker

Description

@amlwwalker

I am trying to compile my plugin with tinygo.

tinygo version                                                                                                                                                                                                                                                                                    tinygo version 0.37.0 darwin/arm64 (using go version go1.24.3 and LLVM version 19.1.2)
go version
go version go1.24.3 darwin/arm64

compiling with


protoc --go-plugin_out=./pkg/pb --go-plugin_opt=paths=source_relative --proto_path=./pkg/proto ./pkg/proto/jetclock.proto

Compiling plugin with

tinygo build -o ./plugins/helloworld.wasm -scheduler=none -target=wasi --no-debug ./cmd/plugins/helloworld/helloworld.go

I get

tinygo build -o ./plugins/helloworld.wasm -scheduler=none -target=wasi --no-debug ./cmd/plugins/helloworld/helloworld.go
# google.golang.org/protobuf/internal/filetype
../../../../pkg/mod/google.golang.org/protobuf@v1.36.6/internal/filetype/build.go:230:21: undefined: reflect.SliceOf

In my .proto I have

import "google/protobuf/empty.proto";
...
service HostFunctions {
  rpc HttpGet(HttpGetRequest) returns (HttpResponse);
  rpc Log(LogRequest) returns (google.protobuf.Empty);
  rpc EmitPluginEvent(PluginEvent) returns (google.protobuf.Empty);
}

My understanding from the known example is that the protoc compiler will use the correct libraries to handle this

but i see in my .pb.go file thats generated


import (
	context "context"
	emptypb "github.com/knqyf263/go-plugin/types/known/emptypb"
	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
)

so this seems like its still using reflection from Google which I understand this should avoid?
Any tips so that I can compile with tinygo?
Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions