如何在Heroku上部署带有MySQL数据库的Go服务器?

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

How to deploy Go server on Heroku with a MySQL database?

问题

我现在是你的中文翻译。以下是翻译好的内容:

我现在完全是一个托管应用程序的初学者,但我正在努力掌握它。

  • 我已经在我的个人电脑上成功运行了MySQL数据库。我应该如何将它托管到在线环境中?
  • 当我尝试在Heroku上部署我的Go服务器时,我遇到了以下错误,并且无法在网上找到解决方案。
-----> App not compatible with buildpack: https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/go.tgz
       More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
 !     Push failed

对此方面的任何帮助将不胜感激!

英文:

I am a complete beginner at hosting applications right now but am trying to get a hold of it.

  • I have the MySQL database running locally on my PC. How to exactly should I host it somewhere online.
  • When I tried to deploy my Go server on Heroku, I got the following error and couldn't find a solution for it anywhere online.
-----> App not compatible with buildpack: https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/go.tgz
       More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
 !     Push failed

Any help in this regard would be appreciated!

答案1

得分: 1

要解决这个问题,你需要使用一些供应商工具,例如Godep、dep等。Heroku无法部署没有'vendor'文件夹的golang应用程序。

英文:

To fix this problem you need to use some of vendoring tools - e.g. Godep, dep etc.
Heroku can't deploy golang app without 'vendor' folder

答案2

得分: 0

只需运行以下命令:

go mod init [app-name]

这将为您创建一个go mod文件和一个go sum文件
然后运行:

go get

以安装您在go应用程序中调用的那些包。
开发人员通常使用go mod init github.com/name/repo
但是go mod init [app-name]
也可以完成任务!

英文:

just run this command:

go mod init [app-name]

this will create a go mod file and a go sum for you
then run:

go get

to install those packages you called in your go app.
developers usually use go mod init github.com/name/repo
but go mod init [app-name]
will do the job!

huangapple
  • 本文由 发表于 2017年8月26日 08:52:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/45890979.html
匿名

发表评论

匿名网友

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

确定