Upgrade to https://blog.golang.org/protobuf-apiv2
This commit is contained in:
64
README.md
64
README.md
@@ -1,34 +1,48 @@
|
||||
# BDChain gRPC API 指南
|
||||
## BDLedger gRPC API
|
||||
|
||||
## 编译 Go 版本 gRPC
|
||||
### Generating gRPC code in languages
|
||||
|
||||
### 安装
|
||||
#### Installling tools
|
||||
|
||||
- [Protocol Buffers 3](https://github.com/protocolbuffers/protobuf/releases)
|
||||
- 下载对应版本,并将可执行程序 `protoc` 的目录加入到环境变量 `PATH` 中
|
||||
- Go > 1.6
|
||||
```bash
|
||||
# 安装 Go 版本相关插件
|
||||
go get -u google.golang.org/grpc
|
||||
go get -u github.com/golang/protobuf/protoc-gen-go
|
||||
```
|
||||
- Node.js
|
||||
```bash
|
||||
npm install -g grpc-tools
|
||||
```
|
||||
- Web
|
||||
```bash
|
||||
git clone https://github.com/grpc/grpc-web
|
||||
cd grpc-web
|
||||
sudo make install-plugin
|
||||
```
|
||||
Download the [Protocol Buffers compiler](https://github.com/protocolbuffers/protobuf/releases) (protoc-3.11.4-*) for your platform and add `protoc` to `PATH` environment variable
|
||||
|
||||
参考资料:
|
||||
For generating Go code:
|
||||
```bash
|
||||
GIT_TAG="v1.4.0-rc.4"
|
||||
go get -d -u github.com/golang/protobuf/protoc-gen-go
|
||||
git -C "$(go env GOPATH)"/src/github.com/golang/protobuf checkout $GIT_TAG
|
||||
go install github.com/golang/protobuf/protoc-gen-go
|
||||
```
|
||||
(Update to google.golang.org/protobuf when https://github.com/grpc/grpc-go/pull/3435 resolves)
|
||||
|
||||
For generating Java code: From `bdledger-sdk-java` run `gradle generateProto`
|
||||
|
||||
For generating Node.js code:
|
||||
```bash
|
||||
npm install -g grpc-tools
|
||||
```
|
||||
For generating TypeScript definitions, also run:
|
||||
```bash
|
||||
npm install -g protoc-gen-ts
|
||||
```
|
||||
|
||||
For frontend JavaScript:
|
||||
```bash
|
||||
git clone https://github.com/grpc/grpc-web
|
||||
cd grpc-web
|
||||
sudo make install-plugin
|
||||
```
|
||||
|
||||
References:
|
||||
- [Go Quick Start](https://grpc.io/docs/quickstart/go.html#prerequisites)
|
||||
- [gRPC Go FAQ](https://github.com/grpc/grpc-go#faq)
|
||||
|
||||
### 编译
|
||||
**TODO: Look into [protobuf.js](https://github.com/protobufjs/protobuf.js) for Nodes.js and frontend**
|
||||
**TODO: Look into [Kroto+](https://github.com/marcoferrer/kroto-plus) for Kotlin**
|
||||
|
||||
- 在本项目打开控制台,或者切换工作路径到本项目
|
||||
- 执行 `./scripts/gen-{{platform}}`
|
||||
#### Generating code
|
||||
|
||||
Run
|
||||
```bash
|
||||
./scripts/gen [go] [nodejs] [ts]
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user