protoc-gen-goexample

command module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 22, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

README

protoc-gen-goexample

An example of a protoc plugin in go

Build

go build .

Run the plugin

protoc --plugin protoc-gen-goexample --goexample_out=output example.proto

Passing additional data to generators

Parameters may be set for additional information

protoc --plugin protoc-gen-goexample --goexample_out=param1=value1,param2=value2:output example.proto

I believe an equivalent, cleaner, way to do this would be using the opt argument

protoc --plugin ./protoc-gen-goexample --goexample_out=output --goexample_opt=param1=value1,param2=value2 example.proto

Parameters shall apply to multiple files. See an example in generateCode for parsing comments. You might consider using annotations as comments to apply additional data at the message level, or field level, by adding annotations as leading comments.

Documentation

Overview

If this program is on the path of your machine you can invoke it in the following way:

protoc --plugin protoc-gen-goexample --goexample_out=output example.proto

Note that the `goexample` term is both the last portion of the binary build and the first portion of the out argument. If you named your plugin `protoc-gen-poodle` then you would need to invoke that plugin by:

protoc --plugin protoc-gen-poodle --poodle_out=output example.proto

Parameters may be set for additional information

protoc --plugin protoc-gen-goexample --goexample_out=param1=value1,param2=value2:output example.proto

I believe an equivalent, cleaner, way to do this would be using the opt argument

protoc --plugin ./protoc-gen-goexample --goexample_out=output --goexample_opt=param1=value1,param2=value2 example.proto

Parameters shall apply to multiple files. See an example in generateCode for applying settings to individual message types using annotations.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL