cmd/protoc-gen-go, runtime/protoimpl: enforce minimum and maximum versions
Generate the needed infrastructure to ensure that we can statically
enforce minimum and maximum versions. This enables us to have a policy
when we release v2 where it fails to build for:
* new generated code with really old runtimes
* new runtimes with really old generated code
Change-Id: Ib699ad62c06dff8f9285806394a741c18db00288
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/178546
Reviewed-by: Damien Neil <dneil@google.com>
diff --git a/internal/testprotos/test/ext.pb.go b/internal/testprotos/test/ext.pb.go
index 9f6915d..58cb656 100644
--- a/internal/testprotos/test/ext.pb.go
+++ b/internal/testprotos/test/ext.pb.go
@@ -11,7 +11,12 @@
sync "sync"
)
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+ // Verify that runtime/protoimpl is sufficiently up-to-date.
+ _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+ // Verify that this generated code is sufficiently up-to-date.
+ _ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
var file_test_ext_proto_extDescs = []protoiface.ExtensionDescV1{
{
diff --git a/internal/testprotos/test/test.pb.go b/internal/testprotos/test/test.pb.go
index cbf1c48..86c69ed 100644
--- a/internal/testprotos/test/test.pb.go
+++ b/internal/testprotos/test/test.pb.go
@@ -12,7 +12,12 @@
sync "sync"
)
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+ // Verify that runtime/protoimpl is sufficiently up-to-date.
+ _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+ // Verify that this generated code is sufficiently up-to-date.
+ _ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
type ForeignEnum int32
diff --git a/internal/testprotos/test/test_import.pb.go b/internal/testprotos/test/test_import.pb.go
index 6bbafe9..2288939 100644
--- a/internal/testprotos/test/test_import.pb.go
+++ b/internal/testprotos/test/test_import.pb.go
@@ -11,7 +11,12 @@
sync "sync"
)
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+ // Verify that runtime/protoimpl is sufficiently up-to-date.
+ _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+ // Verify that this generated code is sufficiently up-to-date.
+ _ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
type ImportEnum int32
diff --git a/internal/testprotos/test/test_public.pb.go b/internal/testprotos/test/test_public.pb.go
index 050bf76..832e324 100644
--- a/internal/testprotos/test/test_public.pb.go
+++ b/internal/testprotos/test/test_public.pb.go
@@ -11,7 +11,12 @@
sync "sync"
)
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+ // Verify that runtime/protoimpl is sufficiently up-to-date.
+ _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+ // Verify that this generated code is sufficiently up-to-date.
+ _ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
type PublicImportMessage struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
diff --git a/internal/testprotos/test/weak/test_weak.pb.go b/internal/testprotos/test/weak/test_weak.pb.go
index 187848d..ba5b8df 100644
--- a/internal/testprotos/test/weak/test_weak.pb.go
+++ b/internal/testprotos/test/weak/test_weak.pb.go
@@ -11,7 +11,12 @@
sync "sync"
)
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+ // Verify that runtime/protoimpl is sufficiently up-to-date.
+ _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+ // Verify that this generated code is sufficiently up-to-date.
+ _ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
type WeakImportMessage struct {
A *int32 `protobuf:"varint,1,opt,name=a" json:"a,omitempty"`