英文:
How are golang projects packaged for deployment?
问题
作为一个来自JVM背景的人,我想知道如何将一个golang项目部署到生产环境中。是否有类似于JAR文件的东西?
是否有一个独立的包管理器可以安装在服务器上,并且有一个依赖清单文件,可以在服务器上运行以下载所有依赖项。我特别不想在服务器上构建项目,因为我们不能在生产环境中安装任何编译器等工具。
谢谢。
英文:
Coming from a JVM background I would like to know how to deploy a golang project to production. Is there an equivalent of a JAR file?
Is there a standalone package manager that can be installed on server and a dependency manifest file which can be run to bring down all dependencies on the server. I specifically do not want to have to build the project on the server as we can't have any compilers etc on production boxes.
thanks.
答案1
得分: 8
如果你运行go install <pkg>
,二进制文件将被放置在$GOPATH/bin
目录下。你可以将该二进制文件复制到另一台具有相同操作系统和架构的机器上。
你也可以进入包含main
包的目录,然后直接运行go build
。二进制文件将被放置在当前目录下。
Go二进制文件中没有依赖项需要跟踪,它是静态链接的。(一些系统库可能是动态链接的,但如果你在相同的操作系统上运行,这不应该是个问题。)
英文:
I you run go install <pkg>
, the binary will be placed in $GOPATH/bin
. You can copy that binary to another machine that has the same OS and architecture.
You can also change into the directory that includes the main
package and just run go build
. The binary will be placed in the current directory.
There are no dependencies in a Go binary for you to track. It is statically linked. (Some system libraries may be dynamically linked, but if you are running on the same OS, this shouldn't be a problem.)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论