protoc-gen-validate icon indicating copy to clipboard operation
protoc-gen-validate copied to clipboard

Include the version of protoc-gen-validate in the generated output

Open remyleone opened this issue 3 years ago • 5 comments

Is your feature request related to a problem? Please describe.

As a user, I would like to know which version is used to generate a particular piece of code that is included in my dependencies.

At the moment I only see:

// Code generated by protoc-gen-validate. DO NOT EDIT.

without any indication of the version used.

Describe the solution you'd like

In the generated file, I would like to see the version of protoc-gen-validate that was used to generate a particular piece of code.

This could be useful in case a bug is fixed in a given generator version and regenerating the code could be a viable solution to a problem.

remyleone avatar Jun 23 '21 09:06 remyleone

I'd like to take this. By the way, it seems we don't have version information in the project. Is it necessary to add a version.go file to define protoc-gen-validate version?

lastchiliarch avatar Jul 15 '21 10:07 lastchiliarch

Hey, go for it! You may be able to get the module version at runtime using https://pkg.go.dev/runtime/debug#ReadBuildInfo

rodaine avatar Jul 15 '21 22:07 rodaine

Is there any way to have a string with semantic versioning directly available in the code instead of relying on runtime introspection? I'm concerned about whether or not the string I will get will be "readable".

remyleone avatar Jul 16 '21 10:07 remyleone

Is there any way to have a string with semantic versioning directly available in the code instead of relying on runtime introspection? I'm concerned about whether or not the string I will get will be "readable".

The reason I'm recommending the use of the BuildInfo is that a version file is often a "lie." For instance, 0.6.1 was released in April, and there have been some commits since then. During that time, if we had a version file, 0.6.1 would be the version provided for any build of any commit since the actual release. Go modules on the other hand respect semver, while also having a consistent scheme for non-release modules.

rodaine avatar Jul 16 '21 16:07 rodaine

@rodaine Would it be something like this: https://github.com/envoyproxy/protoc-gen-validate/pull/516

remyleone avatar Sep 09 '21 15:09 remyleone