https://github.com/navono/proto-compile-example
Compile proto file with batch, shell or Docker
https://github.com/navono/proto-compile-example
docker protobuf protobuf3
Last synced: 24 days ago
JSON representation
Compile proto file with batch, shell or Docker
- Host: GitHub
- URL: https://github.com/navono/proto-compile-example
- Owner: navono
- Created: 2019-05-29T08:32:34.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-03T13:28:08.000Z (over 3 years ago)
- Last Synced: 2025-12-26T18:47:45.161Z (6 months ago)
- Topics: docker, protobuf, protobuf3
- Language: Starlark
- Homepage:
- Size: 433 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# proto_compile_example
`proto` 文件编译示例。
## Prerequisite
### 本地主机编译
- Install `Golang`
- Install `Nodejs` and `Yarn`
- Install `bazel` (可选)
- Download `protoc` from [Github](https://github.com/protocolbuffers/protobuf/releases)
- Install plugins
> go get -u -v github.com/ckaznocha/protoc-gen-lint
>
> go get -d -u github.com/golang/protobuf/protoc-gen-go
>
> go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
>
> go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
>
> yarn
### Docker 编译
安装 `Docker`,同时连接网络。运行:
> ./dockerBuild.cmd
## 文件布局
使用 `API` 的工程默认为 `Go` 工程,同时使用 `Go Module` 进行模块管理。因此此处 `API` 的根目录应该与 `Go` 工程的模块名相同,否则会导致在 `Go` 工程在编译时,无法正确加载 `API` 相关的模块。例如:
> `are` 项目的接口统一放置在此目录下的一个名为 `are` 的目录的 `api` 文件夹内。`proto` 文件编译后,`Go` 的导入也就是这样:
>> import (
v1alpha "are/api/core/v1alpha"
)
>
> 因此要将在 `generated` 下的 `are\api` 整个文件夹拷贝到模块名为 `are` 的工程中。
>
## build
> ./build.sh
## note
注意,`googleapis` 的 `proto` 文件和 `Go` 相应的在 `@go_googleapis` 包下面。由 `@io_bazel_rules_go` 的 `go_rules_dependencies` 进行注册。