Skip to content

Commit

Permalink
refactor: drop protoimpl.EnforceVersion lines
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Stewart <[email protected]>
  • Loading branch information
paralin committed Apr 10, 2024
1 parent a5d225c commit c2353ee
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 30 deletions.
29 changes: 0 additions & 29 deletions cmd/protoc-gen-go-lite/internal_gengo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"github.com/aperturerobotics/protobuf-go-lite/internal/editionssupport"
"github.com/aperturerobotics/protobuf-go-lite/internal/encoding/tag"
"github.com/aperturerobotics/protobuf-go-lite/internal/genid"
"github.com/aperturerobotics/protobuf-go-lite/internal/version"
"google.golang.org/protobuf/reflect/protoreflect"
"google.golang.org/protobuf/runtime/protoimpl"

Expand All @@ -36,9 +35,6 @@ var (
SupportedEditionsMaximum = editionssupport.Maximum
)

// GenerateVersionMarkers specifies whether to generate version markers.
var GenerateVersionMarkers = true

// Standard library dependencies.
const (
base64Package = protogen.GoImportPath("encoding/base64")
Expand Down Expand Up @@ -83,17 +79,6 @@ func GenerateFile(gen *protogen.Plugin, file *protogen.File) *protogen.Generated
g.P(packageDoc, "package ", f.GoPackageName)
g.P()

// Emit a static check that enforces a minimum version of the proto package.
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))
}
Expand Down Expand Up @@ -127,20 +112,6 @@ 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-lite. DO NOT EDIT.")

if GenerateVersionMarkers {
g.P("// versions:")
protocGenGoVersion := version.String()
protocVersion := "(unknown)"
if v := gen.Request.GetCompilerVersion(); v != nil {
protocVersion = fmt.Sprintf("v%v.%v.%v", v.GetMajor(), v.GetMinor(), v.GetPatch())
if s := v.GetSuffix(); s != "" {
protocVersion += "-" + s
}
}
g.P("// \tprotoc-gen-go-lite ", protocGenGoVersion)
g.P("// \tprotoc ", protocVersion)
}

if f.Proto.GetOptions().GetDeprecated() {
g.P("// ", f.Desc.Path(), " is a deprecated file.")
} else {
Expand Down
1 change: 0 additions & 1 deletion internal/cmd/generate-protos/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ func init() {
protogen.Options{}.Run(func(gen *protogen.Plugin) error {
for _, file := range gen.Files {
if file.Generate {
gengo.GenerateVersionMarkers = false
gengo.GenerateFile(gen, file)
generateIdentifiers(gen, file)
generateSourceContextStringer(gen, file)
Expand Down

0 comments on commit c2353ee

Please sign in to comment.