feat: replace protoc-gen-go with buf remote plugin

main
sudo pacman -Syu 2023-06-10 11:11:44 +07:00
parent bcd480a62c
commit de96e78aa9
2 changed files with 16 additions and 22 deletions

View File

@ -65,11 +65,6 @@
</ul>
<p>FYI, the libs version I use:</p>
<ul>
<li>
<a href="https://github.com/golang/protobuf/releases/tag/v1.5.2"
>golang/protobuf v1.5.2</a
>
</li>
<li>
<a
href="https://github.com/grpc-ecosystem/grpc-gateway/releases/tag/v1.16.0"
@ -118,21 +113,21 @@
<div class="highlight highlight-source-yaml">
<pre><span class="pl-ent">version</span>: <span class="pl-c1">v1</span>
<span class="pl-ent">plugins</span>:
- <span class="pl-ent">name</span>: <span class="pl-s">go</span>
- <span class="pl-ent">plugin</span>: <span class="pl-s">buf.build/grpc/go:v1.2.0</span>
<span class="pl-ent">out</span>: <span class="pl-s">pkg</span>
<span class="pl-ent">opt</span>:
- <span class="pl-s">plugins=grpc</span>
- <span class="pl-ent">name</span>: <span class="pl-s">buf.build/bufbuild/validate-go:v0.9.0</span>
- <span class="pl-ent">plugin</span>: <span class="pl-s">buf.build/protocolbuffers/go:v1.28.1</span>
<span class="pl-ent">out</span>: <span class="pl-s">pkg</span>
- <span class="pl-ent">plugin</span>: <span class="pl-s">buf.build/bufbuild/validate-go:v0.9.0</span>
<span class="pl-ent">out</span>: <span class="pl-s">pkg</span>
<span class="pl-ent">opt</span>:
- <span class="pl-s">lang=go</span>
- <span class="pl-ent">name</span>: <span class="pl-s">marshal-zap</span>
- <span class="pl-ent">plugin</span>: <span class="pl-s">marshal-zap</span>
<span class="pl-ent">out</span>: <span class="pl-s">pkg</span>
- <span class="pl-ent">name</span>: <span class="pl-s">grpc-gateway</span>
- <span class="pl-ent">plugin</span>: <span class="pl-s">grpc-gateway</span>
<span class="pl-ent">out</span>: <span class="pl-s">pkg</span>
<span class="pl-ent">opt</span>:
- <span class="pl-s">logtostderr=true</span>
- <span class="pl-ent">name</span>: <span class="pl-s">swagger</span>
- <span class="pl-ent">plugin</span>: <span class="pl-s">swagger</span>
<span class="pl-ent">out</span>: <span class="pl-s">.</span>
<span class="pl-ent">opt</span>:
- <span class="pl-s">logtostderr=true</span></pre>
@ -140,7 +135,6 @@
<p>Update <code>Makefile</code>:</p>
<div class="highlight highlight-source-makefile">
<pre><span class="pl-en">gen</span>:
go install github.com/golang/protobuf/protoc-gen-go
go install github.com/kei2100/protoc-gen-marshal-zap/plugin/protoc-gen-marshal-zap
go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
@ -157,6 +151,7 @@
</p>
<div class="highlight highlight-source-makefile">
<pre><span class="pl-en">raw</span>:
mkdir -p ./raw
cp ./api.proto ./raw/
sed -i "" -e "s/import \"validate\/validate\.proto\";//g" ./raw/api.proto
sed -i "" -e "s/\[(validate\.rules)\.string.min_len = 1\]//g" ./raw/api.proto

View File

@ -10,7 +10,6 @@ We need 3 files:
FYI, the libs version I use:
- [golang/protobuf v1.5.2](https://github.com/golang/protobuf/releases/tag/v1.5.2)
- [grpc-ecosystem/grpc-gateway v1.16.0](https://github.com/grpc-ecosystem/grpc-gateway/releases/tag/v1.16.0)
- [bufbuild/protoc-gen-validate](github.com/bufbuild/protoc-gen-validate)
- [kei2100/protoc-gen-marshal-zap](github.com/kei2100/protoc-gen-marshal-zap)
@ -51,21 +50,21 @@ lint:
```yaml
version: v1
plugins:
- name: go
- plugin: buf.build/grpc/go:v1.2.0
out: pkg
opt:
- plugins=grpc
- name: buf.build/bufbuild/validate-go:v0.9.0
- plugin: buf.build/protocolbuffers/go:v1.28.1
out: pkg
- plugin: buf.build/bufbuild/validate-go:v0.9.0
out: pkg
opt:
- lang=go
- name: marshal-zap
- plugin: marshal-zap
out: pkg
- name: grpc-gateway
- plugin: grpc-gateway
out: pkg
opt:
- logtostderr=true
- name: swagger
- plugin: swagger
out: .
opt:
- logtostderr=true
@ -75,7 +74,6 @@ Update `Makefile`:
```Makefile
gen:
go install github.com/golang/protobuf/protoc-gen-go
go install github.com/kei2100/protoc-gen-marshal-zap/plugin/protoc-gen-marshal-zap
go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
@ -91,6 +89,7 @@ If using `bufbuild/protoc-gen-validate`, `kei2100/protoc-gen-marshal-zap`, bette
```Makefile
raw:
mkdir -p ./raw
cp ./api.proto ./raw/
sed -i "" -e "s/import \"validate\/validate\.proto\";//g" ./raw/api.proto
sed -i "" -e "s/\[(validate\.rules)\.string.min_len = 1\]//g" ./raw/api.proto