我如何手动使用GO工具编译将多个软件包编译到一个可执行文件中

发布于 2025-01-27 22:12:00 字数 265 浏览 2 评论 0原文

由于某些原因,我需要使用“ GO Tool Compile”来编译GO文件,而不是使用自动GO构建。 “ Go Tool Compile”在同一软件包中的一个文件或多个文件可以正常工作,但是如果我的项目结构是:

-package1
--p1.go
-package2
--p2.go
main.go
go.mod

with Main.Go使用Package1和poffage2中定义的符号。 那我应该如何使用:Go Tool编译“最终获得可执行程序?

For some reasons I need to use "go tool compile" to compile go files instead of using the automatic go build.
"go tool compile" works fine with one file or multiple files in the same package, but if my project structure is like:

-package1
--p1.go
-package2
--p2.go
main.go
go.mod

where main.go uses symbols defined in package1 and package2.
Then how am I supposed to use :go tool compile" to eventually get an executable program?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文