Skip to content

Commit

Permalink
feat: managing protobuf with buf
Browse files Browse the repository at this point in the history
managing protobuf with buf
  • Loading branch information
navanis committed Nov 19, 2024
1 parent 496f907 commit fa7ecda
Show file tree
Hide file tree
Showing 32 changed files with 1,252 additions and 5,102 deletions.
82 changes: 0 additions & 82 deletions Makefile

This file was deleted.

18 changes: 18 additions & 0 deletions api/buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: v1

deps:
- 'buf.build/googleapis/googleapis'
- 'buf.build/envoyproxy/protoc-gen-validate'
- 'buf.build/kratos/apis'
- 'buf.build/gnostic/gnostic'
- 'buf.build/gogo/protobuf'
- 'buf.build/tx7do/pagination'

breaking:
use:
- FILE

lint:
use:
- DEFAULT
allow_comment_ignores: true
45 changes: 45 additions & 0 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# 配置protoc生成规则
version: v1

managed:
enabled: true
optimize_for: SPEED

plugins:
# 使用go插件生成go代码
#- plugin: buf.build/protocolbuffers/go
- name: go
out: gen/api/go
opt: paths=source_relative # 使用相对路径

# 使用go-grpc插件生成gRPC服务代码
#- plugin: buf.build/grpc/go
- name: go-grpc
out: gen/api/go
opt:
- paths=source_relative # 使用相对路径

# generate rest service code
- name: go-http
out: gen/api/go
opt:
- paths=source_relative # 使用相对路径

# generate kratos errors code
- name: go-errors
out: gen/api/go
opt:
- paths=source_relative # 使用相对路径

# generate message validator code
#- plugin: buf.build/bufbuild/validate-go
- name: validate
out: gen/api/go
opt:
- paths=source_relative # 使用相对路径
- lang=go

- name: openapi
out: api
opt:
- paths=source_relative
4 changes: 4 additions & 0 deletions buf.work.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
version: v1

directories:
- api
21 changes: 21 additions & 0 deletions internal/conf/buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 配置protoc生成规则
version: v1

managed:
enabled: true
optimize_for: SPEED

plugins:
# 使用go插件生成go代码
#- plugin: buf.build/protocolbuffers/go
- name: go
out: ./
opt: paths=source_relative # 使用相对路径

# generate message validator code
#- plugin: buf.build/bufbuild/validate-go
- name: validate
out: ./
opt:
- paths=source_relative # 使用相对路径
- lang=go
7 changes: 7 additions & 0 deletions internal/conf/buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: v1
breaking:
use:
- FILE
lint:
use:
- DEFAULT
Loading

0 comments on commit fa7ecda

Please sign in to comment.