- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我的项目“testheeroku7777”由两个文件组成。主要Go:
package main
import "fmt"
func main() {
fmt.Println("Hello world!")
}
简介:
web: testheeroku7777
当我推送时:
testheeroku7777> git push heroku master
报错:
Counting objects: 8, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (8/8), 645.21 KiB | 5.92 MiB/s, done.
Total 8 (delta 1), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> App not compatible with buildpack: https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/go.tgz
remote: More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to testheeroku7777.
remote: To https://git.heroku.com/testheeroku7777.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/testheeroku7777.git'
我已阅读提供的链接,但我不知道这个错误。
最佳答案
这个问题与 Go 的新依赖管理系统有关。 Heroku 正在您的项目中寻找依赖管理系统,但找不到。这就是它抛出错误的原因。即使你的项目很简单,Heroku 也必须有一个它可以识别的依赖管理系统。
使用 Go 模块是 officially-sanctioned method依赖管理。但是——这是一个很大的但是——Go 模块的一个令人惊讶的怪癖是 Go 模块不适用于 GOPATH
中的项目。
当 Go 开始时,开发人员做出了一件大事,将所有项目都放在一个地方,GOPATH
。所有文档都明确说明了这一点——这是你的 go 代码必须存储的地方,它不会从其他任何地方运行。但是现在,如果您正在编写需要 Go 模块的代码——并且任何在 heroku 上运行的代码都需要 Go 模块——该代码的目录必须在 GOPATH
之外。我不知道他们为什么不更明确地说明这一点,但事实似乎就是这样。
因此,为了让您的代码正常工作,您需要做的是:
将你的项目移动到 GOPATH
之外的某个地方——比如桌面,以原创的名义。
创建一个与当前名称相同的远程 git 存储库项目。
然后在终端命令中输入 go module 文件在您的本地目录中提示,go mod init
github.com/myGithubUserName/myProjectName
接下来,通过在终端中键入 git init
创建本地 git 存储库。
通过键入 git 来识别您之前创建的远程存储库
中终端。
远程添加来源
http//www.github.com/myGithubUserName/myProjectName.git
写一些优秀的代码。
输入 git add 。 && git commit -m “first commit”
在提示符下提交您的代码。
键入 git push -u origin master
以更新远程存储库。
在所有这些之后,并且只有在所有这些之后,您才准备好输入 git push heroku master
。唯一的安慰是现在一切都应该顺利进行。
其他发帖者提到过早期的依赖管理系统,比如 govendor
和 dep
,但是 Go 模块是官方认可的方法,我想我们现在和以后都要适应它。关于 Go 模块的最受欢迎的教程似乎是这个:https://roberto.selbach.ca/intro-to-go-modules/ .搜索也会找到其他一些。
关于go - 无法将简单的 golang 项目推送到 heroku,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48841627/
我正在尝试运行这段代码,用随机数替换字符串中的一个字符: //Get the position between 0 and the length of the string-1 to insert
我有一个包含 3 个位置的数组,假设它的所有位置都是数字 5。 [5 5 5] 我怎样才能以保持 555 的方式将它传递给 var?就像这样。 n:= 555 最佳答案 与使用任何其他语言的方式相同:
我使用 go dep 工具版本 v0.4.1,现在当我运行 dep init 时它会按预期创建 2 个文件,当我打开 gopkg.lock 我发现例如以下内容 [[projects]] name
我正在制作学习联系申请。我有一个 NewContact()。 // Contact - defines the fields of an entire Contact type Contact str
我一直在尝试使用该模块: https://godoc.org/github.com/hirochachacha/go-smb2#RemoteFile.ReadAt 为了在 Windows 机器上对我的
我需要在 golang 中编译 golang 中的程序。有没有不使用 exec.Command("go","build") 的原生形式? 最佳答案 不幸的是,我认为使用 exec.Command 是利
编写输出有效 go 代码的 go 应用程序可能最好使用内置的“go”包及其一些子包(“go/ast”、“go/token”、“go/printer”、等)。 要创建字符串文字表达式,您需要创建一个 a
我正在尝试使用 Golang 和 gin 为我的 api 和前端编写代理。如果请求转到除“/api”之外的任何内容,我想代理到 svelte 服务器。如果出现“/api/something”,我想在
我偶然发现了这个博客:using go as a scripting language并尝试创建一个可用于运行 golang 脚本的自定义图像,即 FROM golang:1.15 RUN go ge
我刚开始接触golang,我需要从json字符串中获取数据。 {"data" : ["2016-06-21","2016-06-22","2016-06-25"], "sid" : "ab", "di
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题? 更新问题,以便 editing this post 可以用事实和引用来回答它. 关闭 3 年前。 Improve
我是 goland 的新手,试图在我的第一个项目中使用它。我注意到在 goland 中它没有显示通过容器引入的相同 golang SDK。 这是我的 Dockerfile: FROM golang:1
我正在试用 golang-neo4j-bolt-driver 包 github.com/johnnadratowski/golang-neo4j-bolt-driver 我已经导入了包并正在使用创建新
如果我安装了Go发行版软件包,则会在/usr/lib/golang/pkg中看到很多文件,在/usr/lib/golang/src中看到非常相似的文件集。这两组之间有什么关系? pkg是从src中的源
我发现 golang 上下文对于在客户端-服务器请求范围内取消服务器的处理很有用。 我可以使用 http.Request.WithContext 方法发出带有上下文的 http 请求,但是如果客户端不
我正在尝试将一个 golang 数组(还有 slice、struct 等)放置到 HTML 中,这样当从 golang gin web 框架返回 HTML 时,我可以在 HTML 元素内容中使用数组元
目前正在使用这个 ffmpeg 命令编辑视频 ffmpeg -i "video1.ts" -c:v libx264 -crf 20 -c:a aac -strict -2 "video1-fix.ts
我需要从 play.golang.org 链接读取 golang 代码并保存到 .go 文件。我想知道 play.golang.org 是否有任何公共(public) API 支持。我用谷歌搜索但没有
我第一次使用 IntelliJ 的最新 (2014-01-03) Golang 插件。 通常,我的终端工作流程是 go build && ./executable -args=1 所以我试图创建一个启
这个问题只是在构建之间随机出现,现在甚至我们的生产 repo,几个月都没有改变,在构建时也会出现这个问题。我已经坚持了一段时间。它不会发生在我们的本地机器上,只有在使用 dockerfile 时才会发
我是一名优秀的程序员,十分优秀!