zeromicro / go-zero

A cloud-native Go microservices framework with cli tool for productivity.
https://go-zero.dev
MIT License
29.2k stars 3.95k forks source link

How to reference common structs in .api files? #1059

Closed SaneHe closed 2 years ago

SaneHe commented 3 years ago

参照此前 issues 不行的 436,

type Workwechat { Behaviors
Payload wechat.Payload json:"payload" } // goctl api go -api D:/demo/service/push/api/push.api -dir D:/demo/service/push/api // errors: no viable alternative at input 'ypes (\n\tgolang (' (个人理解时不支持 @types 语法)

- import

import "demo/common/conf.api"

type Workwechat { Behaviors
Payload wechat.Payload json:"payload" } error: The system cannot find the path specified.



请问我怎么样做才可以呢
github-actions[bot] commented 3 years ago

This issue is stale because it has been open for 30 days with no activity.

kesonan commented 3 years ago

436 当时设计了这样一个方案,在内测阶段没有得到广泛使用,所以这种场景的解决方案还是重复编写结构体。除此之外,只能通过 import 去避免重复编写,但是 goctl 生成代码的时候还是会将被import的内容会 copy 一份过来的。这个后面我们还是需要重新考量一下场景和解决方案,在保证极简的同时又能满足需求,稳步前进。

github-actions[bot] commented 2 years ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 2 years ago

This issue was closed because it has been inactive for 14 days since being marked as stale.