英文:
Golang binary on Heroku
问题
我已经制作了一个 Golang 应用程序,并且使用 buildpack 在 Heroku 上没有问题,但现在我想将编译好的程序分发给其他人,而不提供源代码。
在 Heroku 上,是否可以让二进制文件正常工作,而不需要源代码?或者 Heroku 需要源代码来创建自己的编译版本?
英文:
I've made a Golang application and I've no problem getting it to work on Heroku using the buildpack but now I would like to distribute the compiled program to others without the source code.
Is it possible to get the binary working on Heroku without the source code or does Heroku need the source code to create its own compiled version?
答案1
得分: 3
Heroku buildpack for Go并没有做任何特殊处理:它只是调用Go工具根据您是否使用godeps来编译二进制文件。
只需在您的package main
目录中调用go build
或go build repo.com/you/yourmainpackage
,即可生成可分发的二进制文件。
此外,如果您希望他人在Heroku上运行提供的二进制文件,您还需要查看此构建包:https://github.com/ph3nx/heroku-binary-buildpack ——请确保该二进制文件已针对Heroku进行了amd64 Linux的编译。
英文:
The Heroku buildpack for Go doesn't do anything special: it just calls out to the Go tool to compile the binary based on whether you use godeps or not.
Just call go build
in the directory of your package main
or go build repo.com/you/yourmainpackage
to output a binary you can distribute.
In addition, you'll want to see this buildpack if you want to have others run a provided binary on Heroku: https://github.com/ph3nx/heroku-binary-buildpack — make sure the binary has been compiled for amd64 Linux if you are targeting Heroku.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论