Hello!
*The question is:*
How can I make protoc generate a pointer to the value?
*The problem:*
I have 2 files in the root directory.
I use Makefile to generate Go code from .proto files.
But the *language* field in the Video struct is a value not a pointer to
the value.
And the *subtitles* field in the Video struct is an array of values not an
array of pointers to the value.
*video.pb.go*
type Video struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id string `protobuf:"bytes,1,opt,name=id,proto3"
json:"id,omitempty"`
Title string `protobuf:"bytes,2,opt,name=title,proto3"
json:"title,omitempty"`
Languages language.ISO639_1
`protobuf:"varint,3,opt,name=languages,proto3,enum=language.ISO639_1"
json:"languages,omitempty"`
Subtitles []language.ISO639_1
`protobuf:"varint,4,rep,packed,name=subtitles,proto3,enum=language.ISO639_1"
json:"subtitles,omitempty"`
}
*Makefile*
gen:
# Video
protoc -I. --go_out=plugins=grpc,paths=source_relative:video video.proto
# Language
protoc -I. --go_out=plugins=grpc,paths=source_relative:language
language.proto
*language.proto*
syntax = "proto3";
package language;
option go_package = "example.com/group/repo/language;language";
enum ISO639_1 {
UNKNOWN = 0;
zh = 1;
}
*video.proto*
syntax = "proto3";
package video;
import "language.proto";
option go_package = "example.com/group/repo/video;video";
message Video {
string id = 1;
string title = 2;
language.ISO639_1 language = 3;
repeated language.ISO639_1 subtitles = 4;
}
--
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/protobuf/eac045ed-aceb-401c-a6ba-1de876c7bfdbo%40googlegroups.com.