PROTOC plug-in call logic for Go

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

To get Protoc to use plugins, you need to do the following:

Place the plugin binary somewhere in the PATH and give it the name "Protoc-gen-name" (replacing "name" with the name of yo ur plugin).

If you then invoke Protoc with the Parameter–name_out=out_dir (again, replace "name" with your plugin ' s name), Protoc wil L Invoke your plugin to generate the output, which'll be is placed in Out_dir.

Place the plugin binary anywhere, with any name, and pass The–plugin parameter to Protoc to direct it to your plugin like So

Protoc--plugin=protoc-gen-name=path/to/mybinary--name_out=out_dir

On Windows, make sure to include the. exe suffix:

Protoc--plugin=protoc-gen-name=path/to/mybinary.exe--name_out=out_dir

Reference: Https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.compiler.plugin

The plugin commands that generate the GRPC code for Go are:

protoc --go_out=plugins=grpc,import_path=mypackage:. *.proto
Here through the--name_out, you can know is the need to find Protoc-gen-name plug-ins, that is, protoc-gen-go plug-ins.
Https://github.com/golang/protobuf/blob/master/protoc-gen-go/grpc/grpc.go  as a plugin.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.