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