If I want to use proto-gen-go of version v1.2.0

118 views
Skip to first unread message

吕逸彬

unread,
Nov 10, 2020, 3:18:09 AM11/10/20
to Protocol Buffers
If I want to use proto-gen-go of version v1.2.0
Which version of protoc should I choose?

Joe Tsai

unread,
Nov 10, 2020, 2:00:29 PM11/10/20
to Protocol Buffers
The exact version of protoc used should not matter that much with regard to the exact version of protoc-gen-go. However, if you want to use one of the newer features of the protobuf language (e.g., proto3 optional), then you'll need a newer version of protoc-gen-go (e.g, v1.25.0).

I should also note that v1.2.0 is fairly old, being released in August, 2018. I recommend using a newer version of protoc-gen-go.

JT

vaibhav mittal

unread,
Sep 27, 2022, 4:18:25 PM9/27/22
to Protocol Buffers
Hi Joe

We are migrating our code base from gogo/protobuf to second version of google.golang.org/protobuf.
We are running into several issues because the new structs have some internal fields namely:- 
    state         protoimpl.MessageState
    sizeCache     protoimpl.SizeCache
    unknownFields protoimpl.UnknownFields

As a result of these proto.equal doesnt work anymore on these structs and we cannot compare maps  and slices.
More importantly we cannot pass these structures as value since it complains with below error:- 
 copies lock value: waf_rules.GlobalSpecType contains google.golang.org/protobuf/internal/impl.MessageState contains sync.Mutex

Are you aware of any option to disable generating these internal fields for the structs or can we change the protoc to not generate these?
Any help would be appreciated. Thanks
Reply all
Reply to author
Forward
0 new messages