Browse Source

runtime/protoimpl, cmd/protoc-gen-go: support release versioning

In order for protoc-gen-go to output the current version,
it needs to know what version it is currently running as.
However, we cannot rely on the git tags since the tags are not
made until *after* the commit has been submitted.
Instead, we manually encode the version into the code and
make sure that git tags match up with the version in the code.

The version.go file in runtime/protoimpl contains instructions
for how to make a release. Essentially:
* Every non-release commit has a version string with "devel" in it.
* Every release commit must not have "devel" in it and must be unique.
* The "release process" involves submitting two CLs.
The first CL creates a version string without "devel",
which is the commit that a git tag will actually reference.
The second CL follows immediately and re-introduces "devel"
into the version string.

The following example shows a possible sequence of VersionStrings
for git commits in time-ascending order:
	v1.19.0-devel      (this CL)
	v1.19.0-devel
	v1.19.0-devel
	v1.19.0-devel
	v1.20.0-rc.1       <- tagged
	v1.20.0-rc.1.devel
	v1.20.0-rc.1.devel
	v1.20.0-rc.1.devel
	v1.20.0-rc.2       <- tagged
	v1.20.0-rc.2.devel
	v1.20.0            <- tagged (future public release)
	v1.20.0-devel
	v1.20.0-devel
	v1.20.0-devel
	v1.20.0-devel
	v1.20.1            <- tagged
	v1.20.1-devel
	v1.20.1-devel
	v1.21.0            <- tagged
	v1.21.0-devel

Note that we start today with v1.19.0-devel, which means that our initial
release will be v1.20.0. This number was intentionally chosen since
1) the number 20 has some correlation to the fact that we keep calling
the new implementation the "v2" implementation, and
2) the set of tagged versions for github.com/golang/protobuf
and google.golang.org/protobuf are unlikely to ever overlap.
This way, the version of protoc-gen-go is never ambiguous which module
it was built from.

Now that we have version information, we add support for generating .pb.go
files with the version information recorded. However, we do not emit
these for .pb.go files in our own repository since they are always guaranteed
to be at the right version (enforced by integration_test.go).

Updates golang/protobuf#524

Change-Id: I25495a45042c2aa39a39cb7e7738ae8e831a9d26
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/186117
Reviewed-by: Damien Neil <dneil@google.com>
Joe Tsai 6 years ago
parent
commit
bab3d4084e
87 changed files with 177 additions and 626 deletions
  1. 0 7
      cmd/protoc-gen-go-grpc/testdata/grpc/deprecation.pb.go
  2. 0 7
      cmd/protoc-gen-go-grpc/testdata/grpc/grpc.pb.go
  3. 41 17
      cmd/protoc-gen-go/internal_gengo/main.go
  4. 9 0
      cmd/protoc-gen-go/main.go
  5. 0 7
      cmd/protoc-gen-go/testdata/annotations/annotations.pb.go
  6. 1 1
      cmd/protoc-gen-go/testdata/annotations/annotations.pb.go.meta
  7. 0 7
      cmd/protoc-gen-go/testdata/comments/comments.pb.go
  8. 0 7
      cmd/protoc-gen-go/testdata/comments/deprecated.pb.go
  9. 0 7
      cmd/protoc-gen-go/testdata/extensions/base/base.pb.go
  10. 0 7
      cmd/protoc-gen-go/testdata/extensions/ext/ext.pb.go
  11. 0 7
      cmd/protoc-gen-go/testdata/extensions/extra/extra.pb.go
  12. 0 7
      cmd/protoc-gen-go/testdata/extensions/proto3/ext3.pb.go
  13. 0 7
      cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go
  14. 0 7
      cmd/protoc-gen-go/testdata/import_public/a.pb.go
  15. 0 7
      cmd/protoc-gen-go/testdata/import_public/b.pb.go
  16. 0 7
      cmd/protoc-gen-go/testdata/import_public/c.pb.go
  17. 0 7
      cmd/protoc-gen-go/testdata/import_public/sub/a.pb.go
  18. 0 7
      cmd/protoc-gen-go/testdata/import_public/sub/b.pb.go
  19. 0 7
      cmd/protoc-gen-go/testdata/import_public/sub2/a.pb.go
  20. 0 7
      cmd/protoc-gen-go/testdata/imports/fmt/m.pb.go
  21. 0 7
      cmd/protoc-gen-go/testdata/imports/test_a_1/m1.pb.go
  22. 0 7
      cmd/protoc-gen-go/testdata/imports/test_a_1/m2.pb.go
  23. 0 7
      cmd/protoc-gen-go/testdata/imports/test_a_2/m3.pb.go
  24. 0 7
      cmd/protoc-gen-go/testdata/imports/test_a_2/m4.pb.go
  25. 0 7
      cmd/protoc-gen-go/testdata/imports/test_b_1/m1.pb.go
  26. 0 7
      cmd/protoc-gen-go/testdata/imports/test_b_1/m2.pb.go
  27. 0 7
      cmd/protoc-gen-go/testdata/imports/test_import_a1m1.pb.go
  28. 0 7
      cmd/protoc-gen-go/testdata/imports/test_import_a1m2.pb.go
  29. 0 7
      cmd/protoc-gen-go/testdata/imports/test_import_all.pb.go
  30. 0 7
      cmd/protoc-gen-go/testdata/issue780_oneof_conflict/test.pb.go
  31. 0 7
      cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go
  32. 0 7
      cmd/protoc-gen-go/testdata/proto2/enum.pb.go
  33. 0 7
      cmd/protoc-gen-go/testdata/proto2/fields.pb.go
  34. 0 7
      cmd/protoc-gen-go/testdata/proto2/nested_messages.pb.go
  35. 0 7
      cmd/protoc-gen-go/testdata/proto2/proto2.pb.go
  36. 0 7
      cmd/protoc-gen-go/testdata/proto3/enum.pb.go
  37. 0 7
      cmd/protoc-gen-go/testdata/proto3/fields.pb.go
  38. 0 7
      encoding/testprotos/pb2/test.pb.go
  39. 0 7
      encoding/testprotos/pb3/test.pb.go
  40. 1 0
      internal/cmd/generate-protos/main.go
  41. 0 7
      internal/testprotos/benchmarks/benchmarks.pb.go
  42. 0 7
      internal/testprotos/benchmarks/datasets/google_message1/proto2/benchmark_message1_proto2.pb.go
  43. 0 7
      internal/testprotos/benchmarks/datasets/google_message1/proto3/benchmark_message1_proto3.pb.go
  44. 0 7
      internal/testprotos/benchmarks/datasets/google_message2/benchmark_message2.pb.go
  45. 0 7
      internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3.pb.go
  46. 0 7
      internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_1.pb.go
  47. 0 7
      internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_2.pb.go
  48. 0 7
      internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_3.pb.go
  49. 0 7
      internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_4.pb.go
  50. 0 7
      internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_5.pb.go
  51. 0 7
      internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_6.pb.go
  52. 0 7
      internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_7.pb.go
  53. 0 7
      internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_8.pb.go
  54. 0 7
      internal/testprotos/benchmarks/datasets/google_message4/benchmark_message4.pb.go
  55. 0 7
      internal/testprotos/benchmarks/datasets/google_message4/benchmark_message4_1.pb.go
  56. 0 7
      internal/testprotos/benchmarks/datasets/google_message4/benchmark_message4_2.pb.go
  57. 0 7
      internal/testprotos/benchmarks/datasets/google_message4/benchmark_message4_3.pb.go
  58. 0 7
      internal/testprotos/conformance/conformance.pb.go
  59. 0 7
      internal/testprotos/conformance/test_messages_proto2.pb.go
  60. 0 7
      internal/testprotos/conformance/test_messages_proto3.pb.go
  61. 0 7
      internal/testprotos/irregular/test.pb.go
  62. 0 7
      internal/testprotos/legacy/legacy.pb.go
  63. 0 7
      internal/testprotos/messageset/messagesetpb/message_set.pb.go
  64. 0 7
      internal/testprotos/messageset/msetextpb/msetextpb.pb.go
  65. 0 7
      internal/testprotos/test/ext.pb.go
  66. 0 7
      internal/testprotos/test/test.pb.go
  67. 0 7
      internal/testprotos/test/test_import.pb.go
  68. 0 7
      internal/testprotos/test/test_public.pb.go
  69. 0 7
      internal/testprotos/test/weak1/test_weak.pb.go
  70. 0 7
      internal/testprotos/test/weak2/test_weak.pb.go
  71. 0 7
      internal/testprotos/test3/test.pb.go
  72. 0 7
      internal/testprotos/test3/test_import.pb.go
  73. 0 7
      reflect/protoregistry/testprotos/test.pb.go
  74. 0 41
      runtime/protoimpl/impl.go
  75. 125 0
      runtime/protoimpl/version.go
  76. 0 7
      types/descriptorpb/descriptor.pb.go
  77. 0 7
      types/known/anypb/any.pb.go
  78. 0 7
      types/known/apipb/api.pb.go
  79. 0 7
      types/known/durationpb/duration.pb.go
  80. 0 7
      types/known/emptypb/empty.pb.go
  81. 0 7
      types/known/fieldmaskpb/field_mask.pb.go
  82. 0 7
      types/known/sourcecontextpb/source_context.pb.go
  83. 0 7
      types/known/structpb/struct.pb.go
  84. 0 7
      types/known/timestamppb/timestamp.pb.go
  85. 0 7
      types/known/typepb/type.pb.go
  86. 0 7
      types/known/wrapperspb/wrappers.pb.go
  87. 0 7
      types/pluginpb/plugin.pb.go

+ 0 - 7
cmd/protoc-gen-go-grpc/testdata/grpc/deprecation.pb.go

@@ -14,13 +14,6 @@ import (
 	sync "sync"
 )
 
-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_grpc_deprecation_proto protoreflect.FileDescriptor
 
 var file_grpc_deprecation_proto_rawDesc = []byte{

+ 0 - 7
cmd/protoc-gen-go-grpc/testdata/grpc/grpc.pb.go

@@ -14,13 +14,6 @@ import (
 	sync "sync"
 )
 
-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 Request struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache

+ 41 - 17
cmd/protoc-gen-go/internal_gengo/main.go

@@ -11,6 +11,7 @@ import (
 	"go/parser"
 	"go/token"
 	"math"
+	"runtime"
 	"strconv"
 	"strings"
 	"unicode"
@@ -25,6 +26,9 @@ import (
 	"google.golang.org/protobuf/types/descriptorpb"
 )
 
+// GenerateVersionMarkers specifies whether to generate version markers.
+var GenerateVersionMarkers = true
+
 const (
 	// generateEnumJSONMethods specifies whether to generate the UnmarshalJSON
 	// method for proto2 enums.
@@ -145,28 +149,21 @@ func GenerateFile(gen *protogen.Plugin, file *protogen.File) *protogen.Generated
 	}
 
 	genStandaloneComments(g, f, fieldnum.FileDescriptorProto_Syntax)
-
-	g.P("// Code generated by protoc-gen-go. DO NOT EDIT.")
-	if f.Proto.GetOptions().GetDeprecated() {
-		g.P("// ", f.Desc.Path(), " is a deprecated file.")
-	} else {
-		g.P("// source: ", f.Desc.Path())
-	}
-	g.P()
-
+	genGeneratedHeader(gen, g, f)
 	genStandaloneComments(g, f, fieldnum.FileDescriptorProto_Package)
-
 	g.P("package ", f.GoPackageName)
 	g.P()
 
 	// Emit a static check that enforces a minimum version of the proto package.
-	g.P("const (")
-	g.P("// Verify that runtime/protoimpl is sufficiently up-to-date.")
-	g.P("_ = ", protoimplPackage.Ident("EnforceVersion"), "(", protoimplPackage.Ident("MaxVersion"), " - ", protoimpl.Version, ")")
-	g.P("// Verify that this generated code is sufficiently up-to-date.")
-	g.P("_ = ", protoimplPackage.Ident("EnforceVersion"), "(", protoimpl.Version, " - ", protoimplPackage.Ident("MinVersion"), ")")
-	g.P(")")
-	g.P()
+	if GenerateVersionMarkers {
+		g.P("const (")
+		g.P("// Verify that this generated code is sufficiently up-to-date.")
+		g.P("_ = ", protoimplPackage.Ident("EnforceVersion"), "(", protoimpl.GenVersion, " - ", protoimplPackage.Ident("MinVersion"), ")")
+		g.P("// Verify that runtime/protoimpl is sufficiently up-to-date.")
+		g.P("_ = ", protoimplPackage.Ident("EnforceVersion"), "(", protoimplPackage.Ident("MaxVersion"), " - ", protoimpl.GenVersion, ")")
+		g.P(")")
+		g.P()
+	}
 
 	for i, imps := 0, f.Desc.Imports(); i < imps.Len(); i++ {
 		genImport(gen, g, f, imps.Get(i))
@@ -209,6 +206,33 @@ func genStandaloneComments(g *protogen.GeneratedFile, f *fileInfo, n int32) {
 	}
 }
 
+func genGeneratedHeader(gen *protogen.Plugin, g *protogen.GeneratedFile, f *fileInfo) {
+	g.P("// Code generated by protoc-gen-go. DO NOT EDIT.")
+
+	if GenerateVersionMarkers {
+		g.P("// versions:")
+		protocGenGoVersion := protoimpl.VersionString()
+		protocVersion := "(unknown)"
+		if v := gen.Request.GetCompilerVersion(); v != nil {
+			protocVersion = fmt.Sprintf("v%v.%v.%v", v.GetMajor(), v.GetMinor(), v.GetPatch())
+		}
+		goVersion := runtime.Version()
+		if strings.HasPrefix(goVersion, "go") {
+			goVersion = "v" + goVersion[len("go"):]
+		}
+		g.P("// \tprotoc-gen-go ", protocGenGoVersion)
+		g.P("// \tprotoc        ", protocVersion)
+		g.P("// \tgo            ", goVersion)
+	}
+
+	if f.Proto.GetOptions().GetDeprecated() {
+		g.P("// ", f.Desc.Path(), " is a deprecated file.")
+	} else {
+		g.P("// source: ", f.Desc.Path())
+	}
+	g.P()
+}
+
 func genImport(gen *protogen.Plugin, g *protogen.GeneratedFile, f *fileInfo, imp protoreflect.FileImport) {
 	impFile, ok := gen.FileByName(imp.Path())
 	if !ok {

+ 9 - 0
cmd/protoc-gen-go/main.go

@@ -9,12 +9,21 @@ package main
 import (
 	"errors"
 	"flag"
+	"fmt"
+	"os"
+	"path/filepath"
 
 	gengo "google.golang.org/protobuf/cmd/protoc-gen-go/internal_gengo"
 	"google.golang.org/protobuf/compiler/protogen"
+	"google.golang.org/protobuf/runtime/protoimpl"
 )
 
 func main() {
+	if len(os.Args) == 2 && os.Args[1] == "--version" {
+		fmt.Fprintf(os.Stderr, "%v %v\n", filepath.Base(os.Args[0]), protoimpl.VersionString())
+		os.Exit(1)
+	}
+
 	var (
 		flags        flag.FlagSet
 		plugins      = flags.String("plugins", "", "deprecated option")

+ 0 - 7
cmd/protoc-gen-go/testdata/annotations/annotations.pb.go

@@ -15,13 +15,6 @@ import (
 	sync "sync"
 )
 
-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 AnnotationsTestEnum int32
 
 const (

+ 1 - 1
cmd/protoc-gen-go/testdata/annotations/annotations.pb.go.meta

@@ -1 +1 @@
-annotation:{path:5 path:0 source_file:"annotations/annotations.proto" begin:750 end:769} annotation:{path:5 path:0 path:2 path:0 source_file:"annotations/annotations.proto" begin:786 end:833} annotation:{path:4 path:0 source_file:"annotations/annotations.proto" begin:2113 end:2135} annotation:{path:4 path:0 path:2 path:0 source_file:"annotations/annotations.proto" begin:2259 end:2279} annotation:{path:4 path:0 path:2 path:0 source_file:"annotations/annotations.proto" begin:3173 end:3196}
+annotation:{path:5 path:0 source_file:"annotations/annotations.proto" begin:501 end:520} annotation:{path:5 path:0 path:2 path:0 source_file:"annotations/annotations.proto" begin:537 end:584} annotation:{path:4 path:0 source_file:"annotations/annotations.proto" begin:1864 end:1886} annotation:{path:4 path:0 path:2 path:0 source_file:"annotations/annotations.proto" begin:2010 end:2030} annotation:{path:4 path:0 path:2 path:0 source_file:"annotations/annotations.proto" begin:2924 end:2947}

+ 0 - 7
cmd/protoc-gen-go/testdata/comments/comments.pb.go

@@ -18,13 +18,6 @@ import (
 	sync "sync"
 )
 
-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)
-)
-
 // COMMENT: Enum1.Leading
 type Enum1 int32
 

+ 0 - 7
cmd/protoc-gen-go/testdata/comments/deprecated.pb.go

@@ -15,13 +15,6 @@ import (
 	sync "sync"
 )
 
-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)
-)
-
 // Deprecated: Do not use.
 type DeprecatedEnum int32
 

+ 0 - 7
cmd/protoc-gen-go/testdata/extensions/base/base.pb.go

@@ -15,13 +15,6 @@ import (
 	sync "sync"
 )
 
-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 BaseMessage struct {
 	state           protoimpl.MessageState
 	sizeCache       protoimpl.SizeCache

+ 0 - 7
cmd/protoc-gen-go/testdata/extensions/ext/ext.pb.go

@@ -18,13 +18,6 @@ import (
 	sync "sync"
 )
 
-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 Enum int32
 
 const (

+ 0 - 7
cmd/protoc-gen-go/testdata/extensions/extra/extra.pb.go

@@ -14,13 +14,6 @@ import (
 	sync "sync"
 )
 
-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 ExtraMessage struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache

+ 0 - 7
cmd/protoc-gen-go/testdata/extensions/proto3/ext3.pb.go

@@ -17,13 +17,6 @@ import (
 	sync "sync"
 )
 
-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 Enum int32
 
 const (

+ 0 - 7
cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go

@@ -14,13 +14,6 @@ import (
 	sync "sync"
 )
 
-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)
-)
-
 // Assorted edge cases in field name conflict resolution.
 //
 // Not all (or possibly any) of these behave in an easily-understood fashion.

+ 0 - 7
cmd/protoc-gen-go/testdata/import_public/a.pb.go

@@ -15,13 +15,6 @@ import (
 	sync "sync"
 )
 
-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)
-)
-
 // Symbols defined in public import of import_public/sub/a.proto.
 
 type E = sub.E

+ 0 - 7
cmd/protoc-gen-go/testdata/import_public/b.pb.go

@@ -15,13 +15,6 @@ import (
 	sync "sync"
 )
 
-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 Local struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache

+ 0 - 7
cmd/protoc-gen-go/testdata/import_public/c.pb.go

@@ -15,13 +15,6 @@ import (
 	sync "sync"
 )
 
-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 UsingPublicImport struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache

+ 0 - 7
cmd/protoc-gen-go/testdata/import_public/sub/a.pb.go

@@ -18,13 +18,6 @@ import (
 	sync "sync"
 )
 
-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)
-)
-
 // Symbols defined in public import of import_public/sub2/a.proto.
 
 type Sub2Message = sub2.Sub2Message

+ 0 - 7
cmd/protoc-gen-go/testdata/import_public/sub/b.pb.go

@@ -14,13 +14,6 @@ import (
 	sync "sync"
 )
 
-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 M2 struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache

+ 0 - 7
cmd/protoc-gen-go/testdata/import_public/sub2/a.pb.go

@@ -14,13 +14,6 @@ import (
 	sync "sync"
 )
 
-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 Sub2Message struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache

+ 0 - 7
cmd/protoc-gen-go/testdata/imports/fmt/m.pb.go

@@ -14,13 +14,6 @@ import (
 	sync "sync"
 )
 
-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 M struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache

+ 0 - 7
cmd/protoc-gen-go/testdata/imports/test_a_1/m1.pb.go

@@ -15,13 +15,6 @@ import (
 	sync "sync"
 )
 
-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 E1 int32
 
 const (

+ 0 - 7
cmd/protoc-gen-go/testdata/imports/test_a_1/m2.pb.go

@@ -14,13 +14,6 @@ import (
 	sync "sync"
 )
 
-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 M2 struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache

+ 0 - 7
cmd/protoc-gen-go/testdata/imports/test_a_2/m3.pb.go

@@ -14,13 +14,6 @@ import (
 	sync "sync"
 )
 
-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 M3 struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache

+ 0 - 7
cmd/protoc-gen-go/testdata/imports/test_a_2/m4.pb.go

@@ -14,13 +14,6 @@ import (
 	sync "sync"
 )
 
-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 M4 struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache

+ 0 - 7
cmd/protoc-gen-go/testdata/imports/test_b_1/m1.pb.go

@@ -14,13 +14,6 @@ import (
 	sync "sync"
 )
 
-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 M1 struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache

+ 0 - 7
cmd/protoc-gen-go/testdata/imports/test_b_1/m2.pb.go

@@ -14,13 +14,6 @@ import (
 	sync "sync"
 )
 
-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 M2 struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache

+ 0 - 7
cmd/protoc-gen-go/testdata/imports/test_import_a1m1.pb.go

@@ -15,13 +15,6 @@ import (
 	sync "sync"
 )
 
-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 A1M1 struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache

+ 0 - 7
cmd/protoc-gen-go/testdata/imports/test_import_a1m2.pb.go

@@ -15,13 +15,6 @@ import (
 	sync "sync"
 )
 
-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 A1M2 struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache

+ 0 - 7
cmd/protoc-gen-go/testdata/imports/test_import_all.pb.go

@@ -18,13 +18,6 @@ import (
 	sync "sync"
 )
 
-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 All struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache

+ 0 - 7
cmd/protoc-gen-go/testdata/issue780_oneof_conflict/test.pb.go

@@ -10,13 +10,6 @@ import (
 	sync "sync"
 )
 
-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 Foo struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache

+ 0 - 7
cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go

@@ -15,13 +15,6 @@ import (
 	sync "sync"
 )
 
-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 Enum int32
 
 const (

+ 0 - 7
cmd/protoc-gen-go/testdata/proto2/enum.pb.go

@@ -15,13 +15,6 @@ import (
 	sync "sync"
 )
 
-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)
-)
-
 // EnumType1 comment.
 type EnumType1 int32
 

+ 0 - 7
cmd/protoc-gen-go/testdata/proto2/fields.pb.go

@@ -16,13 +16,6 @@ import (
 	sync "sync"
 )
 
-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 FieldTestMessage_Enum int32
 
 const (

+ 0 - 7
cmd/protoc-gen-go/testdata/proto2/nested_messages.pb.go

@@ -14,13 +14,6 @@ import (
 	sync "sync"
 )
 
-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 Layer1 struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache

+ 0 - 7
cmd/protoc-gen-go/testdata/proto2/proto2.pb.go

@@ -14,13 +14,6 @@ import (
 	sync "sync"
 )
 
-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 Message struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache

+ 0 - 7
cmd/protoc-gen-go/testdata/proto3/enum.pb.go

@@ -15,13 +15,6 @@ import (
 	sync "sync"
 )
 
-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 Enum int32
 
 const (

+ 0 - 7
cmd/protoc-gen-go/testdata/proto3/fields.pb.go

@@ -15,13 +15,6 @@ import (
 	sync "sync"
 )
 
-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 FieldTestMessage_Enum int32
 
 const (

+ 0 - 7
encoding/testprotos/pb2/test.pb.go

@@ -25,13 +25,6 @@ import (
 	sync "sync"
 )
 
-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 Enum int32
 
 const (

+ 0 - 7
encoding/testprotos/pb3/test.pb.go

@@ -17,13 +17,6 @@ import (
 	sync "sync"
 )
 
-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 Enum int32
 
 const (

+ 1 - 0
internal/cmd/generate-protos/main.go

@@ -53,6 +53,7 @@ func init() {
 					if file.Generate {
 						switch plugin {
 						case "go":
+							gengo.GenerateVersionMarkers = false
 							gengo.GenerateFile(gen, file)
 							generateFieldNumbers(gen, file)
 						case "gogrpc":

+ 0 - 7
internal/testprotos/benchmarks/benchmarks.pb.go

@@ -40,13 +40,6 @@ import (
 	sync "sync"
 )
 
-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 BenchmarkDataset struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache

+ 0 - 7
internal/testprotos/benchmarks/datasets/google_message1/proto2/benchmark_message1_proto2.pb.go

@@ -12,13 +12,6 @@ import (
 	sync "sync"
 )
 
-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 GoogleMessage1 struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache

+ 0 - 7
internal/testprotos/benchmarks/datasets/google_message1/proto3/benchmark_message1_proto3.pb.go

@@ -12,13 +12,6 @@ import (
 	sync "sync"
 )
 
-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 GoogleMessage1 struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache

+ 0 - 7
internal/testprotos/benchmarks/datasets/google_message2/benchmark_message2.pb.go

@@ -12,13 +12,6 @@ import (
 	sync "sync"
 )
 
-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 GoogleMessage2 struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache

+ 0 - 7
internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3.pb.go

@@ -11,13 +11,6 @@ import (
 	sync "sync"
 )
 
-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 GoogleMessage3 struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache

+ 0 - 7
internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_1.pb.go

@@ -11,13 +11,6 @@ import (
 	sync "sync"
 )
 
-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 Message34390 struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache

+ 0 - 7
internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_2.pb.go

@@ -11,13 +11,6 @@ import (
 	sync "sync"
 )
 
-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 Message22853 struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache

+ 0 - 7
internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_3.pb.go

@@ -10,13 +10,6 @@ import (
 	sync "sync"
 )
 
-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 Message35546 struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache

+ 0 - 7
internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_4.pb.go

@@ -11,13 +11,6 @@ import (
 	sync "sync"
 )
 
-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 Message24346 struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache

+ 0 - 7
internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_5.pb.go

@@ -11,13 +11,6 @@ import (
 	sync "sync"
 )
 
-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 Message24377 struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache

+ 0 - 7
internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_6.pb.go

@@ -11,13 +11,6 @@ import (
 	sync "sync"
 )
 
-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 Message10576 struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache

+ 0 - 7
internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_7.pb.go

@@ -10,13 +10,6 @@ import (
 	sync "sync"
 )
 
-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 Message11018 struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache

+ 0 - 7
internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_8.pb.go

@@ -11,13 +11,6 @@ import (
 	sync "sync"
 )
 
-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 Enum720 int32
 
 const (

+ 0 - 7
internal/testprotos/benchmarks/datasets/google_message4/benchmark_message4.pb.go

@@ -11,13 +11,6 @@ import (
 	sync "sync"
 )
 
-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 GoogleMessage4 struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache

+ 0 - 7
internal/testprotos/benchmarks/datasets/google_message4/benchmark_message4_1.pb.go

@@ -11,13 +11,6 @@ import (
 	sync "sync"
 )
 
-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 Message2463 struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache

+ 0 - 7
internal/testprotos/benchmarks/datasets/google_message4/benchmark_message4_2.pb.go

@@ -10,13 +10,6 @@ import (
 	sync "sync"
 )
 
-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 Message12774 struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache

+ 0 - 7
internal/testprotos/benchmarks/datasets/google_message4/benchmark_message4_3.pb.go

@@ -11,13 +11,6 @@ import (
 	sync "sync"
 )
 
-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 UnusedEnum int32
 
 const (

+ 0 - 7
internal/testprotos/conformance/conformance.pb.go

@@ -41,13 +41,6 @@ import (
 	sync "sync"
 )
 
-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 WireFormat int32
 
 const (

+ 0 - 7
internal/testprotos/conformance/test_messages_proto2.pb.go

@@ -47,13 +47,6 @@ import (
 	sync "sync"
 )
 
-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 ForeignEnumProto2 int32
 
 const (

+ 0 - 7
internal/testprotos/conformance/test_messages_proto3.pb.go

@@ -54,13 +54,6 @@ import (
 	sync "sync"
 )
 
-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
 
 const (

+ 0 - 7
internal/testprotos/irregular/test.pb.go

@@ -18,13 +18,6 @@ import (
 	sync "sync"
 )
 
-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 Message struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache

+ 0 - 7
internal/testprotos/legacy/legacy.pb.go

@@ -26,13 +26,6 @@ import (
 	sync "sync"
 )
 
-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 Legacy struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache

+ 0 - 7
internal/testprotos/messageset/messagesetpb/message_set.pb.go

@@ -15,13 +15,6 @@ import (
 	sync "sync"
 )
 
-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 MessageSet struct {
 	state           protoimpl.MessageState
 	sizeCache       protoimpl.SizeCache

+ 0 - 7
internal/testprotos/messageset/msetextpb/msetextpb.pb.go

@@ -16,13 +16,6 @@ import (
 	sync "sync"
 )
 
-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 Ext1 struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache

+ 0 - 7
internal/testprotos/test/ext.pb.go

@@ -15,13 +15,6 @@ import (
 	sync "sync"
 )
 
-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{
 	{
 		ExtendedType:  (*TestAllExtensions)(nil),

+ 0 - 7
internal/testprotos/test/test.pb.go

@@ -16,13 +16,6 @@ import (
 	sync "sync"
 )
 
-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
 
 const (

+ 0 - 7
internal/testprotos/test/test_import.pb.go

@@ -15,13 +15,6 @@ import (
 	sync "sync"
 )
 
-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
 
 const (

+ 0 - 7
internal/testprotos/test/test_public.pb.go

@@ -14,13 +14,6 @@ import (
 	sync "sync"
 )
 
-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 {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache

+ 0 - 7
internal/testprotos/test/weak1/test_weak.pb.go

@@ -14,13 +14,6 @@ import (
 	sync "sync"
 )
 
-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 WeakImportMessage1 struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache

+ 0 - 7
internal/testprotos/test/weak2/test_weak.pb.go

@@ -14,13 +14,6 @@ import (
 	sync "sync"
 )
 
-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 WeakImportMessage2 struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache

+ 0 - 7
internal/testprotos/test3/test.pb.go

@@ -15,13 +15,6 @@ import (
 	sync "sync"
 )
 
-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
 
 const (

+ 0 - 7
internal/testprotos/test3/test_import.pb.go

@@ -15,13 +15,6 @@ import (
 	sync "sync"
 )
 
-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
 
 const (

+ 0 - 7
reflect/protoregistry/testprotos/test.pb.go

@@ -18,13 +18,6 @@ import (
 	sync "sync"
 )
 
-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 Enum1 int32
 
 const (

+ 0 - 41
runtime/protoimpl/impl.go

@@ -17,51 +17,10 @@ import (
 	"google.golang.org/protobuf/internal/impl"
 )
 
-const (
-	// MaxVersion is the maximum supported version for generated .pb.go files;
-	// which is the current version of the package.
-	// This is incremented when the functionality of this package expands.
-	MaxVersion = 0
-
-	// MinVersion is the minimum supported version for generated .pb.go files.
-	// This is incremented when the runtime drops support for old code.
-	MinVersion = 0
-
-	// Version is the current minor version of the runtime.
-	Version = MaxVersion // v2.{Version}.x
-
-	// TODO: Encode a date instead of the minor version?
-)
-
 // UnsafeEnabled specifies whether package unsafe can be used.
 const UnsafeEnabled = impl.UnsafeEnabled
 
 type (
-	// EnforceVersion is used by code generated by protoc-gen-go
-	// to statically enforce minimum and maximum versions of this package.
-	// A compilation failure implies either that:
-	//	* the runtime package is too old and needs to be updated OR
-	//	* the generated code is too old and needs to be regenerated.
-	//
-	// The runtime package can be upgraded by running:
-	//	go get google.golang.org/protobuf
-	//
-	// The generated code can be regenerated by running:
-	//	protoc --go_out=${PROTOC_GEN_GO_ARGS} ${PROTO_FILES}
-	//
-	// Example usage by generated code:
-	//	const (
-	//		// Verify that runtime/protoimpl is sufficiently up-to-date.
-	//		_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - genVersion)
-	//		// Verify that this generated code is sufficiently up-to-date.
-	//		_ = protoimpl.EnforceVersion(genVersion - protoimpl.MinVersion)
-	//	)
-	//
-	// The genVersion is the current version used to generated the code.
-	// This compile-time check relies on negative integer overflow of a uint
-	// being a compilation failure (guaranteed by the Go specification).
-	EnforceVersion uint
-
 	DescBuilder      = filedesc.Builder
 	TypeBuilder      = filetype.Builder
 	Pointer          = impl.Pointer

+ 125 - 0
runtime/protoimpl/version.go

@@ -0,0 +1,125 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package protoimpl
+
+import (
+	"fmt"
+	"strings"
+)
+
+// These constants determine the current version of this module.
+//
+//
+// For our release process, we enforce the following rules:
+//	* Tagged releases use a tag that is identical to VersionString.
+//	* Tagged releases never reference a commit where the VersionString
+//	contains "devel".
+//	* The set of all commits in this repository where VersionString
+//	does not contain "devel" must have a unique VersionString.
+//
+//
+// Steps for tagging a new release:
+//	1. Create a new CL.
+//
+//	2. Update versionMinor, versionPatch, and/or versionPreRelease as necessary.
+//	versionPreRelease must not contain the string "devel".
+//
+//	3. Since the last released minor version, have there been any changes to
+//	generator that relies on new functionality in the runtime?
+//	If yes, then increment GenVersion.
+//
+//	4. Since the last released minor version, have there been any changes to
+//	the runtime that removes support for old .pb.go source code?
+//	If yes, then increment MinVersion.
+//
+//	5. Send out the CL for review and submit it.
+//	Note that the next CL in step 8 must be submitted after this CL
+//	without any other CLs in-between.
+//
+//	6. Tag a new version, where the tag is is the current VersionString.
+//
+//	7. Write release notes for all notable changes
+//	between this release and the last release.
+//
+//	8. Create a new CL.
+//
+//	9. Update versionPreRelease to include the string "devel".
+//	For example: "" -> "devel" or "rc.1" -> "rc.1.devel"
+//
+//	10. Send out the CL for review and submit it.
+const (
+	versionMajor      = 1
+	versionMinor      = 19
+	versionPatch      = 0
+	versionPreRelease = "devel"
+)
+
+// VersionString formats the version string for this module in semver format.
+//
+// Examples:
+//	v1.20.1
+//	v1.21.0-rc.1
+func VersionString() string {
+	v := fmt.Sprintf("v%d.%d.%d", versionMajor, versionMinor, versionPatch)
+	if versionPreRelease != "" {
+		v += "-" + versionPreRelease
+
+		// TODO: Add metadata about the commit or build hash.
+		// See https://golang.org/issue/29814
+		// See https://golang.org/issue/33533
+		var versionMetadata string
+		if strings.Contains(versionPreRelease, "devel") && versionMetadata != "" {
+			v += "+" + versionMetadata
+		}
+	}
+	return v
+}
+
+const (
+	// MaxVersion is the maximum supported version for generated .pb.go files.
+	// It is always the current version of the module.
+	MaxVersion = versionMinor
+
+	// GenVersion is the runtime version required by generated .pb.go files.
+	// This is incremented when generated code relies on new functionality
+	// in the runtime.
+	GenVersion = 19
+
+	// MinVersion is the minimum supported version for generated .pb.go files.
+	// This is incremented when the runtime drops support for old code.
+	MinVersion = 0
+)
+
+// EnforceVersion is used by code generated by protoc-gen-go
+// to statically enforce minimum and maximum versions of this package.
+// A compilation failure implies either that:
+//	* the runtime package is too old and needs to be updated OR
+//	* the generated code is too old and needs to be regenerated.
+//
+// The runtime package can be upgraded by running:
+//	go get google.golang.org/protobuf
+//
+// The generated code can be regenerated by running:
+//	protoc --go_out=${PROTOC_GEN_GO_ARGS} ${PROTO_FILES}
+//
+// Example usage by generated code:
+//	const (
+//		// Verify that this generated code is sufficiently up-to-date.
+//		_ = protoimpl.EnforceVersion(genVersion - protoimpl.MinVersion)
+//		// Verify that runtime/protoimpl is sufficiently up-to-date.
+//		_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - genVersion)
+//	)
+//
+// The genVersion is the current minor version used to generated the code.
+// This compile-time check relies on negative integer overflow of a uint
+// being a compilation failure (guaranteed by the Go specification).
+type EnforceVersion uint
+
+// This enforces the following invariant:
+//	MinVersion ≤ GenVersion ≤ MaxVersion
+const (
+	_ = EnforceVersion(GenVersion - MinVersion)
+	_ = EnforceVersion(MaxVersion - GenVersion)
+)

+ 0 - 7
types/descriptorpb/descriptor.pb.go

@@ -50,13 +50,6 @@ import (
 	sync "sync"
 )
 
-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 FieldDescriptorProto_Type int32
 
 const (

+ 0 - 7
types/known/anypb/any.pb.go

@@ -40,13 +40,6 @@ import (
 	sync "sync"
 )
 
-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)
-)
-
 // `Any` contains an arbitrary serialized protocol buffer message along with a
 // URL that describes the type of the serialized message.
 //

+ 0 - 7
types/known/apipb/api.pb.go

@@ -42,13 +42,6 @@ import (
 	sync "sync"
 )
 
-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)
-)
-
 // Api is a light-weight descriptor for an API Interface.
 //
 // Interfaces are also described as "protocol buffer services" in some contexts,

+ 0 - 7
types/known/durationpb/duration.pb.go

@@ -40,13 +40,6 @@ import (
 	sync "sync"
 )
 
-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)
-)
-
 // A Duration represents a signed, fixed-length span of time represented
 // as a count of seconds and fractions of seconds at nanosecond
 // resolution. It is independent of any calendar and concepts like "day"

+ 0 - 7
types/known/emptypb/empty.pb.go

@@ -40,13 +40,6 @@ import (
 	sync "sync"
 )
 
-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)
-)
-
 // A generic empty message that you can re-use to avoid defining duplicated
 // empty messages in your APIs. A typical example is to use it as the request
 // or the response type of an API method. For instance:

+ 0 - 7
types/known/fieldmaskpb/field_mask.pb.go

@@ -40,13 +40,6 @@ import (
 	sync "sync"
 )
 
-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)
-)
-
 // `FieldMask` represents a set of symbolic field paths, for example:
 //
 //     paths: "f.a"

+ 0 - 7
types/known/sourcecontextpb/source_context.pb.go

@@ -40,13 +40,6 @@ import (
 	sync "sync"
 )
 
-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)
-)
-
 // `SourceContext` represents information about the source of a
 // protobuf element, like the file in which it is defined.
 type SourceContext struct {

+ 0 - 7
types/known/structpb/struct.pb.go

@@ -41,13 +41,6 @@ import (
 	sync "sync"
 )
 
-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)
-)
-
 // `NullValue` is a singleton enumeration to represent the null value for the
 // `Value` type union.
 //

+ 0 - 7
types/known/timestamppb/timestamp.pb.go

@@ -40,13 +40,6 @@ import (
 	sync "sync"
 )
 
-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)
-)
-
 // A Timestamp represents a point in time independent of any time zone or local
 // calendar, encoded as a count of seconds and fractions of seconds at
 // nanosecond resolution. The count is relative to an epoch at UTC midnight on

+ 0 - 7
types/known/typepb/type.pb.go

@@ -43,13 +43,6 @@ import (
 	sync "sync"
 )
 
-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)
-)
-
 // The syntax in which a protocol buffer element is defined.
 type Syntax int32
 

+ 0 - 7
types/known/wrapperspb/wrappers.pb.go

@@ -50,13 +50,6 @@ import (
 	sync "sync"
 )
 
-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)
-)
-
 // Wrapper message for `double`.
 //
 // The JSON representation for `DoubleValue` is JSON number.

+ 0 - 7
types/pluginpb/plugin.pb.go

@@ -57,13 +57,6 @@ import (
 	sync "sync"
 )
 
-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)
-)
-
 // The version number of protocol compiler.
 type Version struct {
 	state         protoimpl.MessageState