mirror of
https://github.com/zeromicro/go-zero.git
synced 2026-06-22 18:01:57 +08:00
docs: add Korean translations (#5579)
Co-authored-by: kevin <wanjunfeng@gmail.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
# 示例 08:外部 Proto — 不同 `go_package`
|
||||
|
||||
[English](README.md) | 中文 | [한국어](README-ko.md)
|
||||
|
||||
本示例演示从外部目录导入 proto 文件,且文件具有**不同**的 `go_package` 值,需要在生成的 Go 代码中进行跨包导入。
|
||||
|
||||
## Proto 定义
|
||||
@@ -18,7 +20,8 @@ proto 文件使用不同的 `go_package` 值:
|
||||
│ └── types.proto # 外部 proto(go_package = "example.com/demo/pb/common")
|
||||
├── service.proto # 服务定义(go_package = "example.com/demo/pb")
|
||||
├── README.md
|
||||
└── README-cn.md
|
||||
├── README-cn.md
|
||||
└── README-ko.md
|
||||
```
|
||||
|
||||
- `types.proto` 的 `go_package = "example.com/demo/pb/common"` — **不同**的 Go 包。
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
# 예제 08: 외부 proto — 다른 `go_package`
|
||||
|
||||
[English](README.md) | [中文](README-cn.md) | 한국어
|
||||
|
||||
이 예제는 파일들이 **서로 다른** `go_package` 값을 가져 생성된 Go 코드에 패키지 간 import가 필요한 외부 디렉터리의 proto 파일을 import하는 방법을 보여줍니다.
|
||||
|
||||
## proto 정의
|
||||
|
||||
proto 파일들은 서로 다른 `go_package` 값을 사용합니다.
|
||||
|
||||
- `service.proto`: `go_package = "example.com/demo/pb"`
|
||||
- `ext_protos/common/types.proto`: `go_package = "example.com/demo/pb/common"`
|
||||
|
||||
소스 레이아웃:
|
||||
|
||||
```
|
||||
08-external-proto-diff-pkg/
|
||||
├── ext_protos
|
||||
│ └── common
|
||||
│ └── types.proto # 외부 proto (go_package = "example.com/demo/pb/common")
|
||||
├── service.proto # 서비스 정의 (go_package = "example.com/demo/pb")
|
||||
├── README.md
|
||||
├── README-cn.md
|
||||
└── README-ko.md
|
||||
```
|
||||
|
||||
- `types.proto`는 `go_package = "example.com/demo/pb/common"`을 가지며, 이는 **다른** Go 패키지입니다.
|
||||
- `service.proto`는 `common.ExtReq` / `common.ExtReply`를 RPC 파라미터 타입으로 직접 사용합니다.
|
||||
|
||||
## 생성 명령
|
||||
|
||||
먼저 출력 디렉터리에 `go.mod`를 초기화합니다.
|
||||
|
||||
```bash
|
||||
mkdir -p output && cd output && go mod init example.com/demo && cd ..
|
||||
```
|
||||
|
||||
그런 다음 코드를 생성합니다(`-I ./ext_protos`에 주목하세요).
|
||||
|
||||
```bash
|
||||
goctl rpc protoc service.proto \
|
||||
--go_out=output \
|
||||
--go-grpc_out=output \
|
||||
--zrpc_out=output \
|
||||
--go_opt=module=example.com/demo \
|
||||
--go-grpc_opt=module=example.com/demo \
|
||||
--module=example.com/demo \
|
||||
-I . -I ./ext_protos
|
||||
```
|
||||
|
||||
생성되는 디렉터리 구조:
|
||||
|
||||
```
|
||||
output/
|
||||
├── dataservice
|
||||
│ └── dataservice.go
|
||||
├── etc
|
||||
│ └── svc.yaml
|
||||
├── go.mod
|
||||
├── internal
|
||||
│ ├── config
|
||||
│ │ └── config.go
|
||||
│ ├── logic
|
||||
│ │ └── fetchlogic.go
|
||||
│ ├── server
|
||||
│ │ └── dataserviceserver.go
|
||||
│ └── svc
|
||||
│ └── servicecontext.go
|
||||
├── pb
|
||||
│ ├── common
|
||||
│ │ └── types.pb.go
|
||||
│ ├── service.pb.go
|
||||
│ └── service_grpc.pb.go
|
||||
└── svc.go
|
||||
```
|
||||
|
||||
## 핵심 사항
|
||||
|
||||
- 외부 proto가 **다른** `go_package`를 가지면 goctl은 패키지 간 Go import를 자동으로 생성합니다.
|
||||
- goctl은 import된 proto의 `go_package` 옵션을 파싱하여 proto `package` 이름(예: `common`)을 올바른 Go import 경로로 해결합니다.
|
||||
- `service.proto`는 `common.ExtReq` / `common.ExtReply`를 RPC 파라미터 타입으로 직접 사용합니다.
|
||||
@@ -1,5 +1,7 @@
|
||||
# Example 08: External Proto — Different `go_package`
|
||||
|
||||
English | [中文](README-cn.md) | [한국어](README-ko.md)
|
||||
|
||||
This example demonstrates importing proto files from an external directory where the files have **different** `go_package` values, requiring cross-package imports in the generated Go code.
|
||||
|
||||
## Proto Definition
|
||||
@@ -18,7 +20,8 @@ Source layout:
|
||||
│ └── types.proto # External proto (go_package = "example.com/demo/pb/common")
|
||||
├── service.proto # Service definition (go_package = "example.com/demo/pb")
|
||||
├── README.md
|
||||
└── README-cn.md
|
||||
├── README-cn.md
|
||||
└── README-ko.md
|
||||
```
|
||||
|
||||
- `types.proto` has `go_package = "example.com/demo/pb/common"` — a **different** Go package.
|
||||
|
||||
Reference in New Issue
Block a user