在Heroku上运行Golang二进制文件

huangapple go评论80阅读模式
英文:

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 buildgo 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.

huangapple
  • 本文由 发表于 2015年6月28日 17:09:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/31097929.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定