go安装gRPC和Protobuf
go安装gRPC和Protobuf
- 安装Protocol Buffers编译器(protoc)
- 安装gRPC Go插件
- 安装gRPC库
- 附件(protoc.exe)
要在Go中安装gRPC和Protocol Buffers (Protobuf),你需要执行以下步骤:
- 安装Protocol Buffers编译器(protoc)
- 安装gRPC Go插件
- 安装gRPC库
安装Protocol Buffers编译器(protoc)
# 在Linux/macOS上
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v$(protoc --version)/protoc-$(protoc --version)-linux-x86_64.zip
unzip protoc-$(protoc --version)-linux-x86_64.zip -d protoc
sudo mv protoc/bin/protoc /usr/local/bin/# 在Windows上
# 从https://github.com/protocolbuffers/protobuf/releases下载protoc.exe并添加到PATH
安装gRPC Go插件
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
安装gRPC库
go get google.golang.org/grpc
go get google.golang.org/protobuf/proto
go get google.golang.org/protobuf/reflect/protoreflect
go get google.golang.org/protobuf/runtime/protoimpl
附件(protoc.exe)
protoc-28.2-win64.zip