feat: replace protoc-gen-go with buf remote plugin
parent
bcd480a62c
commit
de96e78aa9
|
@ -65,11 +65,6 @@
|
||||||
</ul>
|
</ul>
|
||||||
<p>FYI, the libs version I use:</p>
|
<p>FYI, the libs version I use:</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
|
||||||
<a href="https://github.com/golang/protobuf/releases/tag/v1.5.2"
|
|
||||||
>golang/protobuf v1.5.2</a
|
|
||||||
>
|
|
||||||
</li>
|
|
||||||
<li>
|
<li>
|
||||||
<a
|
<a
|
||||||
href="https://github.com/grpc-ecosystem/grpc-gateway/releases/tag/v1.16.0"
|
href="https://github.com/grpc-ecosystem/grpc-gateway/releases/tag/v1.16.0"
|
||||||
|
@ -118,21 +113,21 @@
|
||||||
<div class="highlight highlight-source-yaml">
|
<div class="highlight highlight-source-yaml">
|
||||||
<pre><span class="pl-ent">version</span>: <span class="pl-c1">v1</span>
|
<pre><span class="pl-ent">version</span>: <span class="pl-c1">v1</span>
|
||||||
<span class="pl-ent">plugins</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">out</span>: <span class="pl-s">pkg</span>
|
||||||
<span class="pl-ent">opt</span>:
|
- <span class="pl-ent">plugin</span>: <span class="pl-s">buf.build/protocolbuffers/go:v1.28.1</span>
|
||||||
- <span class="pl-s">plugins=grpc</span>
|
<span class="pl-ent">out</span>: <span class="pl-s">pkg</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/bufbuild/validate-go:v0.9.0</span>
|
||||||
<span class="pl-ent">out</span>: <span class="pl-s">pkg</span>
|
<span class="pl-ent">out</span>: <span class="pl-s">pkg</span>
|
||||||
<span class="pl-ent">opt</span>:
|
<span class="pl-ent">opt</span>:
|
||||||
- <span class="pl-s">lang=go</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">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">out</span>: <span class="pl-s">pkg</span>
|
||||||
<span class="pl-ent">opt</span>:
|
<span class="pl-ent">opt</span>:
|
||||||
- <span class="pl-s">logtostderr=true</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">out</span>: <span class="pl-s">.</span>
|
||||||
<span class="pl-ent">opt</span>:
|
<span class="pl-ent">opt</span>:
|
||||||
- <span class="pl-s">logtostderr=true</span></pre>
|
- <span class="pl-s">logtostderr=true</span></pre>
|
||||||
|
@ -140,7 +135,6 @@
|
||||||
<p>Update <code>Makefile</code>:</p>
|
<p>Update <code>Makefile</code>:</p>
|
||||||
<div class="highlight highlight-source-makefile">
|
<div class="highlight highlight-source-makefile">
|
||||||
<pre><span class="pl-en">gen</span>:
|
<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/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-grpc-gateway
|
||||||
go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
|
go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
|
||||||
|
@ -157,6 +151,7 @@
|
||||||
</p>
|
</p>
|
||||||
<div class="highlight highlight-source-makefile">
|
<div class="highlight highlight-source-makefile">
|
||||||
<pre><span class="pl-en">raw</span>:
|
<pre><span class="pl-en">raw</span>:
|
||||||
|
mkdir -p ./raw
|
||||||
cp ./api.proto ./raw/
|
cp ./api.proto ./raw/
|
||||||
sed -i "" -e "s/import \"validate\/validate\.proto\";//g" ./raw/api.proto
|
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
|
sed -i "" -e "s/\[(validate\.rules)\.string.min_len = 1\]//g" ./raw/api.proto
|
||||||
|
|
|
@ -10,7 +10,6 @@ We need 3 files:
|
||||||
|
|
||||||
FYI, the libs version I use:
|
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)
|
- [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)
|
- [bufbuild/protoc-gen-validate](github.com/bufbuild/protoc-gen-validate)
|
||||||
- [kei2100/protoc-gen-marshal-zap](github.com/kei2100/protoc-gen-marshal-zap)
|
- [kei2100/protoc-gen-marshal-zap](github.com/kei2100/protoc-gen-marshal-zap)
|
||||||
|
@ -51,21 +50,21 @@ lint:
|
||||||
```yaml
|
```yaml
|
||||||
version: v1
|
version: v1
|
||||||
plugins:
|
plugins:
|
||||||
- name: go
|
- plugin: buf.build/grpc/go:v1.2.0
|
||||||
out: pkg
|
out: pkg
|
||||||
opt:
|
- plugin: buf.build/protocolbuffers/go:v1.28.1
|
||||||
- plugins=grpc
|
out: pkg
|
||||||
- name: buf.build/bufbuild/validate-go:v0.9.0
|
- plugin: buf.build/bufbuild/validate-go:v0.9.0
|
||||||
out: pkg
|
out: pkg
|
||||||
opt:
|
opt:
|
||||||
- lang=go
|
- lang=go
|
||||||
- name: marshal-zap
|
- plugin: marshal-zap
|
||||||
out: pkg
|
out: pkg
|
||||||
- name: grpc-gateway
|
- plugin: grpc-gateway
|
||||||
out: pkg
|
out: pkg
|
||||||
opt:
|
opt:
|
||||||
- logtostderr=true
|
- logtostderr=true
|
||||||
- name: swagger
|
- plugin: swagger
|
||||||
out: .
|
out: .
|
||||||
opt:
|
opt:
|
||||||
- logtostderr=true
|
- logtostderr=true
|
||||||
|
@ -75,7 +74,6 @@ Update `Makefile`:
|
||||||
|
|
||||||
```Makefile
|
```Makefile
|
||||||
gen:
|
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/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-grpc-gateway
|
||||||
go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
|
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
|
```Makefile
|
||||||
raw:
|
raw:
|
||||||
|
mkdir -p ./raw
|
||||||
cp ./api.proto ./raw/
|
cp ./api.proto ./raw/
|
||||||
sed -i "" -e "s/import \"validate\/validate\.proto\";//g" ./raw/api.proto
|
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
|
sed -i "" -e "s/\[(validate\.rules)\.string.min_len = 1\]//g" ./raw/api.proto
|
||||||
|
|
Loading…
Reference in New Issue