go-zero icon indicating copy to clipboard operation
go-zero copied to clipboard

Exception occurs when using multilevel directory nesting in .api group: demo/login due to types file separation

Open ouyang6559 opened this issue 1 year ago • 7 comments

Exception occurs when using multilevel directory nesting in .api group: demo/login due to types file separation

Error message: 2025/05/20 21:06:44 open internal/types/demo/login.go: no such file or directory

@server ( // Represents that the route generation code under the current service code block will be placed in the login directory group: demo/login // Defines the route prefix as "/v1" prefix: /v1 )

The following example can be generated: @server ( // Represents that the route generation code under the current service code block will be placed in the login directory group: login // Defines the route prefix as "/v1" prefix: /v1 )


当.api的group: demo/login多层级目录嵌套会因为types的分文件导致异常

报错内容 2025/05/20 21:06:44 open internal/types/demo/login.go: no such file or directory

@server ( // 代表当前 service 代码块下的路由生成代码时都会被放到 login 目录下 group: demo/login // 定义路由前缀为 "/v1" prefix: /v1 )

下面这一种是可以生成的 @server ( // 代表当前 service 代码块下的路由生成代码时都会被放到 login 目录下 group: login // 定义路由前缀为 "/v1" prefix: /v1 )

Image

ouyang6559 avatar May 20 '25 13:05 ouyang6559

goctl version 1.8.3,今天也遇到这个问题

cqjokers avatar May 20 '25 13:05 cqjokers

1.8.3 问题多多,还有inport api 后重复生成的问题

alex86w avatar May 21 '25 14:05 alex86w

it fixed on master branch

kesonan avatar May 23 '25 03:05 kesonan

I have watched the gotl source code for release 1.8.3 and found that this issue can be resolved by disabling the GOCTL.exe PERIMENTAL environment to disable the new API feature. However, it seems that this variable has always been enabled by default, so I haven't dealt with it either.

Image

Image

At the same time, I solved this problem by using the latest version of goctl to enable API features. The main reason for upgrading is because I want to use the swagger generation function of the gotl API. After using it, I fixed the issue with the gotl swagger plugin. I would like to know if the official and stable 1.8.4 version of gotl will be released soon.

Image

vibe-sudo avatar May 23 '25 10:05 vibe-sudo

Yes, within 2 weeks. go-zero usuallly release every month.

kevwan avatar May 24 '25 08:05 kevwan

Fixed in master. close now, reopen if needed.

kevwan avatar May 24 '25 08:05 kevwan

Fixed in master. close now, reopen if needed. Okay, actually I have solved my problem using v1.8.4 alpha version, but I will still wait for a more stable v1.8.4.

vibe-sudo avatar May 26 '25 03:05 vibe-sudo