Protobuf files for Vanus
- install plugin 'Protocol Buffer' in marketplace
- config path: Performance -> Language&Framework -> Proto Buffers -> Import paths;
and add
include
andproto
directory to
# 1. Install with Homebrew
brew install protobuf
# or download https://github.com/protocolbuffers/protobuf/releases/download/v3.19.4/protoc-3.19.4-osx-x86_64.zip
#unzip protoc-3.19.4-osx-x86_64.zip
#mv bin/protoc $GOPATH/bin/
# 2. Install protoc-gen-go, protoc-gen-go-grpc and protoc-gen-go-grpc-mock
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
go install github.com/sorcererxw/protoc-gen-go-grpc-mock@latest
The makefile has pre-define some convenient methods to generate go file from proto, see file content for details.
# set package, such as controller, then generate code
package=controller make generate-pb
brew install bufbuild/buf/buf
go install github.com/sorcererxw/protoc-gen-go-grpc-mock@latest
cd proto/proto
buf generate
The Visual Studio Code extension can be downloaded from the in-editor extension browser under the name "Buf" or manually via the extension page. You need to have buf installed to use it.
IntelliJ IDEA, GoLand and other JetBrains IDEs can be configured with a File Watcher that runs buf lint --path
on save and optionally surface issues as warnings or errors in your editor.
See this doc for more details.