恢复到protoc gen go的早期版本

恢复到protoc gen go的早期版本,go,protocol-buffers,protobuf-go,Go,Protocol Buffers,Protobuf Go,我正试图将protobuf文件编译成golang。编译后,我在生成的pb.go中看到了这一点 // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.23.0 // protoc v3.12.3 及 但是,以前生成的pb.go // This is a compile-time assertion to ensure that this generated file /

我正试图将protobuf文件编译成golang。编译后,我在生成的pb.go中看到了这一点

// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
//  protoc-gen-go v1.23.0
//  protoc        v3.12.3

但是,以前生成的pb.go

// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package

在proto包的版本4中,代码中断。如何进行编译,使其在版本3中具有ProtoPackage?

问题似乎在于旧版本的
protobuf
lib
ProtoPackageIsVersion3
适用于1.3.*而
ProtoPackageIsVersion4
适用于1.4+,您可以在此处看到更新:

我建议更新到较新的版本,因为googleapis也依赖于较新的版本。看


如果出于某种原因,您仍然需要使用所有内容的旧版本,则需要1.3.5版的
protobuf
,并且很可能需要手动构建
proto-gen-go
protoc
以匹配。您可以在这里看到类似的步骤问题:

问题似乎与旧版本的
protobuf
lib有关
ProtoPackageIsVersion3
适用于1.3.*而
ProtoPackageIsVersion4
适用于1.4+,您可以在此处看到更新:

我建议更新到较新的版本,因为googleapis也依赖于较新的版本。看

如果出于某种原因,您仍然需要使用所有内容的旧版本,则需要1.3.5版的
protobuf
,并且很可能需要手动构建
proto-gen-go
protoc
以匹配。您可以在以下步骤中看到类似的问题:

// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package