cloudwego / cloudwego/fastpb

特定情况下代码生成错误。没有正确的使用 go package

Open
#27 0 comments 0 reactions 0 assignees View on GitHub
C-bug
Dominant language
Go
Stars
109
Forks
9
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**

https://github.com/cloudwego/kitex/issues/1624

**To Reproduce**

- model.proto :
```
syntax = "proto3";

package svc;
option go_package = "svc/model";

message Model {
// 这里定义一个嵌套的 message
message SubModel {
int64 id = 1;
}

int64 id = 1;
string name = 2;
}
```

- req.proto
```
syntax = "proto3";

package svc; // 这里 proto 的 package 与 model.proto 相同
option go_package = "svc/req"; // 这里 go 的package 与 model.proto 不同

import "model.proto"; // 这里引入 model

message Req {
Model md = 1; // 这个引用,在 go 代码中能正确加上 model package
Model.SubModel = 2; // 这个引用,没有加 model package 导致编译错误
}
```
使用 kitex 生成 fastapi

```
kitex -I ${PBPATH} ./req.proto
```

生成的 fastapi 代码中,Model 类型的引用缺少 go package

**Screenshots**
![image](https://github.com/user-attachments/assets/a4ec79da-6fcf-445d-b1cb-e0f532ef7543)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.