您好我正在尝试用 Go 语言生成简单的 protobuf 文件
syntax = "proto3";
package gen;
message EvtKeepAlive
{
string SvcName = 2;
}
在标题中,我看到该包使用了两种不同的 proto go 实现,一种来自 github.com 一个来自 google.golang.org .据我了解,后者取代了前者,那么这个文件生成是否有效?// versions:
// protoc-gen-go v1.25.0-devel
// protoc v3.13.0
// source: common.proto
package gen
import (
proto "github.com/golang/protobuf/proto"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
最佳答案
文件有效;请参阅 dsnet 对 this issue 的回复:
The only reason the newly generated .pb.go files depend on the deprecated proto package is to enforce a weak dependency on a sufficiently new version of the legacy package. This is necessary because not everyone is using Go modules such that the Go toolchain would enforce this dependency constraint. I wasn't fond of adding it, but I think it's probably necessary to keep at least for a few months.
关于Go protobuf 包冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63772572/