使用本地软件包在Heroku上使用应用程序 [英] Go App On Heroku With Local Packages
问题描述
我正在尝试使用转到Buildpack 在Heroku上放置Go应用,当它是一个基本的东西时是很好的,但只要我做一个本地包,它就不会编译。这里有一个示例设置:
Structure
+ ship
+ foo
foo.go
main.go
main.go
软件包主要
导入(
os
fmt
net / http
ship / foo
)
func main(){
foo.Bar()
port: = os.Getenv(PORT)
http.HandleFunc(/,root)
http.ListenAndServe(:+ port,nil)
}
func root(w http.ResponseWriter,r * http.Request){
fmt.Fprint(w,Aloha,world!)
}
foo.go
包foo
func Bar(){}
按
git push heroku master
初始化仓库,完成。
计数对象:20,完成。
使用多达8个线程的增量压缩。
压缩对象:100%(13/13),完成。
写作对象:100%(20/20),1.53 MiB | 586.00 KiB / s,完成。
共20(增量2),重用0(增量0)
----->获取定制git buildpack ... done
-----> Go app detected
----->安装go1.3.1 ... done
----->正在运行:godep go install -tags heroku。/ ...
main.go:7:3:在
/ app / tmp / cache / go1中找不到软件包ship / foo。 3.1 / go / src / pkg / ship / foo(来自$ GOROOT)
/tmp/build_4b92e51c-3959-4ddb-8eff-90d72da70729/.heroku/g/src/_/Users/Daryl/Go/src/ ship / Godeps / _workspace / src / ship / foo(from $ GOPATH)
/tmp/build_4b92e51c-3959-4ddb-8eff-90d72da70729/.heroku/g/src/ship/foo
godep:go退出状态1
!推送被拒绝,未能编译Go应用程序
git push heroku master
初始化仓库,完成。
计数对象:20,完成。
使用多达8个线程的增量压缩。
压缩对象:100%(13/13),完成。
写作对象:100%(20/20),1.53 MiB | 586.00 KiB / s,完成。
共20(增量2),重用0(增量0)
----->获取定制git buildpack ... done
-----> Go app detected
----->安装go1.3.1 ... done
----->正在运行:godep go install -tags heroku。/ ...
main.go:7:3:在
/ app / tmp / cache / go1中找不到软件包ship / foo。 3.1 / go / src / pkg / ship / foo(来自$ GOROOT)
/tmp/build_4b92e51c-3959-4ddb-8eff-90d72da70729/.heroku/g/src/_/Users/Daryl/Go/src/ ship / Godeps / _workspace / src / ship / foo(from $ GOPATH)
/tmp/build_4b92e51c-3959-4ddb-8eff-90d72da70729/.heroku/g/src/ship/foo
godep:go退出状态1
!推送被拒绝,未能编译Go应用程序
任何想法这里发生了什么以及如何去做?
只要注意1.6中遇到此问题的任何人。 Godep已改为使用Heroku的供应商文件夹,因此您需要根据以下文档重置您的Godeps以使用供应商:
https://github.com/tools/godep#go-15-vendor-experiment p>
Heroku也有升级信息:
articles / go-support#migrate-from-go1-5-godep-workspace-to-go1-6-with-a-vendor-directoryrel =nofollow> https://devcenter.heroku.com/articles/ go-support#从-go1-5迁移到godep-workspace-to-go1-6 -a-vendor-directoryI'm trying to put a Go app on Heroku using the Go Buildpack, which is fine when it's something basic, but as soon as I do a local package it does not compile. Here's an example setup:
Structure
+ship
+foo
foo.go
main.go
main.go
package main
import (
"os"
"fmt"
"net/http"
"ship/foo"
)
func main() {
foo.Bar()
port := os.Getenv("PORT")
http.HandleFunc("/", root)
http.ListenAndServe(":" + port, nil)
}
func root(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "Aloha, world!")
}
foo.go
package foo
func Bar() {}
Push
git push heroku master
Initializing repository, done.
Counting objects: 20, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (13/13), done.
Writing objects: 100% (20/20), 1.53 MiB | 586.00 KiB/s, done.
Total 20 (delta 2), reused 0 (delta 0)
-----> Fetching custom git buildpack... done
-----> Go app detected
-----> Installing go1.3.1... done
-----> Running: godep go install -tags heroku ./...
main.go:7:3: cannot find package "ship/foo" in any of:
/app/tmp/cache/go1.3.1/go/src/pkg/ship/foo (from $GOROOT)
/tmp/build_4b92e51c-3959-4ddb-8eff-90d72da70729/.heroku/g/src/_/Users/Daryl/Go/src/ship/Godeps/_workspace/src/ship/foo (from $GOPATH)
/tmp/build_4b92e51c-3959-4ddb-8eff-90d72da70729/.heroku/g/src/ship/foo
godep: go exit status 1
! Push rejected, failed to compile Go app
Any idea what's going on here and how to go about it?
Just a note for anyone coming across this issue in go 1.6. Godep has changed to use a vendor folder with Heroku instead, so you will need to reset your Godeps to use vendor as per the docs here:
https://github.com/tools/godep#go-15-vendor-experiment
Heroku also has upgrade info here:
这篇关于使用本地软件包在Heroku上使用应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!