Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/ghttp: 接口或 enums 越多,构建的二进制文件内容大小激增 #3863

Open
shuqingzai opened this issue Oct 17, 2024 · 4 comments
Labels

Comments

@shuqingzai
Copy link

Go version

go version go1.21.13 darwin/amd64

GoFrame version

2.7.3

Can this bug be reproduced with the latest release?

Option Yes

What did you do?

当项目接口越多或 enums 越多时,编译文件会变得非常大,我不清楚是 ghttp 还是 enums 的问题,当接口只有少量时,不明显,但是对比使用其它 http 组件也大得很

What did you see happen?

线上项目

  1. 编译前期项目只有 “200M”(这其实很夸张了~~~)
    image

使用 Zxilly/go-size-analyzer 分析,rodata 有 40多 M
image

  1. 当我往项目添加更多接口,接口包含许多 enums 时,编译的二进制文件非常夸张(注意:这期间并没有添加其他更多的第三方包之类,最大的改动仅仅是添加更多接口与 enums

image

最后完成了一个比较大的需求(多了 接口 和 enums),二进制文件居然达到 700MB ,这离得破 G 不远了

image

__rodata __TEXT 有 400多 M

image

What did you expect to see?

编译文件的容量十分夸张

@shuqingzai shuqingzai added the bug It is confirmed a bug, but don't worry, we'll handle it. label Oct 17, 2024
@shuqingzai shuqingzai changed the title os/gtime: issue title net/ghttp: 接口或 enums 越多,构建的二进制文件内容大小激增 Oct 17, 2024
@ninjashixuan
Copy link

ninjashixuan commented Nov 12, 2024

生成 enums 时注意不要扫描全部代码只扫描定义 enums 的文件,不然就生成一堆无用的。

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


When generating enums, be careful not to scan the entire code and only scan the files that define enums, otherwise a bunch of useless code will be generated. The problem of many interfaces: Do not configure openApiPath in the production environment. Naturally, swagger documents will not be generated because there are many interfaces and the texts of swagger openapi are not small.

@gqcn
Copy link
Member

gqcn commented Nov 14, 2024

@shuqingzai @ninjashixuan 可以使用prefixes配置参数来控制只生成指定前缀的enums,具体请参考文档 https://goframe.org/docs/cli/gen-enums

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@shuqingzai @ninjashixuan You can use the prefixes configuration parameter to control the generation of only enums with specified prefixes. For details, please refer to the document https://goframe.org/docs/cli/gen-enums

@gqcn gqcn added question and removed bug It is confirmed a bug, but don't worry, we'll handle it. labels Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants