Protocol buffer && GPRC &&golang

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

Never understand the relationship between Protocbuf and Grpc, in fact, want to think in this way can understand protocbuf is a data structure or format, GRPC is an implementation of RPC framework.

Mac uses protocol buffer, first using

 brew install protobuf

, some other dependent packages are downloaded and installed, and GRPC can be installed by

brew install grpc

I installed the PROTOBUF version is 3.2, found that the Mac version has default support for Swift, is really a good news, the only regret is that Google's own home Golang need to install plug-ins independently, how also did not want to understand.
Install Golang plug-in is actually a simpler command, but sometimes you actually installed, but found the call command, found that the call is not, first of all, a prerequisite is that your Mac first installed the Golang language pack, and configured the export Go_root export Environment variables such as Go_path. and create a directory of files such as Go_work on your Mac
PROTOBUF Golang plug-ins need to be individually downloaded and installed separately
1. Get the Protobuf compiler plugin provided by Goprotobuf Protoc-gen-go

go get github.com/golang/protobuf/protoc-gen-go

Or

go get -a github.com/golang/protobuf/protoc-gen-go-a 参数标示下载好后直接做 go install
protoc --go_out=. msg.proto

If the command cannot be run or cannot be found, the description
1. There may be a problem with your GO environment variable, be sure to add it to the PATH variable $GO _root/bin, $GO _path/bin,
If it is not convenient to modify the environment variables, you can go directly to your go language configuration in the Go_work directory of the bin directory, you will find
Protoc-gen-go file,


Paste_image.png

Then find the root directory of your PROTOC command file in terminal

which is  protoc

Will find the directory where my protoc command file is located


Paste_image.png


Then open Finder, shortcut keys

 shift+command +g  跳转到这个文件夹

, and copy the protoc-gen-go paste to this directory
Try the command again and find the smooth execution

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.