GO: Proto Buffer
Doc:
https://developers.google.com/protocol-buffers/docs/gotutorial
Proto Buffer
Download Proto Buffer:
https://developers.google.com/protocol-buffers/docs/downloads
Check if protoc
installed
1 | protoc --version |
Install protoc-gen-go
1 | go install google.golang.org/protobuf/cmd/protoc-gen-go@latest |
Add these text to ~/.bashrc
or ~/.zshrc
(depends on what shell you use)
1 | export GOPATH=$HOME/go |
This step is important to avoid Error "protoc-gen-go: program not found or is not executable"
.proto
File
.proto
example:
1 | syntax = "proto3"; |
Scaffolding:
1 | project/ |
Compile
1 | cd proto |
plugins=grpc
is needed or the output file will lack some functions
Install grpc
1 | go get -u google.golang.org/grpc |
Reference
- How to Solve Error: unable to determine go import path: https://developpaper.com/protocol-gen-go-unable-to-determine-go-import-path-when-exporting-protocol/