问题描述
我已经用Go编写了一个应用程序.它具有两个外部依赖,在编译之前需要满足这些依赖.在Go生态系统中,对于一个简单的安装过程(包括安装这些远程Dep),打包此应用的最佳方法是什么?用户将如何安装我的应用?
I've written an application in Go. It has two external dependencies that would need to be met before compiling. In the Go ecosystem, what is the best way to package this app for a simple installation process that includes installing those remote deps? How would a user install my app?
推荐答案
-
如果您希望用户编译您的应用程序,并且该应用程序依赖于第三方程序包或资产,那么我建议您仅对支持的平台进行交叉编译并提供二进制文件.
If you are expecting a user to compile your application, and that application relies on third party packages or assets, then I'd suggest just cross-compiling for the supported platforms and providing binaries.
如果您要与应用程序一起提供资产(例如配置文件),则可以:a)将二进制文件与资产打包在一起,并用tar/zip压缩;b)对资产进行base64编码,然后将其编译为二进制在此处找到一个很好的示例,或者c)创建一个构建/安装脚本为用户做到这一点.
If you have assets that you want to provide alongside the application (a config file, for example) then either: a) package the binary with the assets and tar/zip it up; b) base64 encode the assets and compile them into the binary see here for a good example or c) create a build/install script that does this for the user.
如果您可以明确要求,则可以更轻松地直接回答.
If you can clarify your exact requirements it'll be easier to answer more directly.
这篇关于如何分发Go应用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!