我使用以下命令为golang生成原型代码:
protoc --go_out=../generated --go_opt=paths=source_relative \
--go-grpc_out=../generated --go-grpc_opt=paths=source_relative \
*.proto我使用内置的google/protobuf/struct.proto来处理非结构化数据。但是,我收到一个错误,说"google.protobuf.Struct“没有定义。
发布于 2021-05-30 03:15:34
protoc由./bin和./include目录组成。
./include应该包括例如google/protobuf/struct.proto。
如果您正确地将PATH设置为./protoc../bin,那么struct.proto应该包含在编译中。
示例
go.mod
module github.com/some/test
go 1.16
require google.golang.org/protobuf v1.26.0test.proto
syntax = "proto3";
package test;
import "google/protobuf/struct.proto";
option go_package = "github.com/some/test;test";
message SomeRequest {
google.protobuf.Struct some_struct = 1;
}然后:
protoc \
--go_out=. \
--go_opt=module=github.com/some/test \
test.protohttps://stackoverflow.com/questions/67754241
复制相似问题