This plugin is just for educational purpose which shows how we can create our own custom protoc plugin to generate custom code based on .proto files.
In this demo we are trying to generate code based on the custom protobuf options.
We are specifying a custom MessagOption name validateEmail and if it true we are generating a function name ValidateEmail in our custom coded file.
Internal folder contain the newly generated code
In examples directory you will find example usage of different packages of protobuf-go so you can get the idea of its usage.
Install Prequisites
Clone the project
git clone git@github.com:salmanbao/custom-protoc-plugin.gitGo to the project directory
cd custom-protoc-pluginInstall dependencies
go mod tidyCompile and run
chmod +x ./compile
./compilein our compile file we are executing our command where we are passing dbtag as a custom tag for newly generated structs