2016-08-13 20 views
3

我想部署在Heroku Go應用程序,但我得到了這樣的錯誤:依存關係轉到應用中不通過godep安裝在Heroku

remote: -----> Go app detected 
remote: -----> Checking Godeps/Godeps.json file. 
remote: -----> Using go1.6.3 
remote: !! Installing package '.' (default) 
remote: !!  
remote: !!  
remote: -----> Running: go install -v -tags heroku . 
remote: main.go:9:2: cannot find package "github.com/go-martini/martini" in any of: 
remote:  /app/tmp/cache/go1.6.3/go/src/github.com/go-martini/martini (from $GOROOT) 
remote:  /tmp/build_3c0222e075a91a3363e590a0169d6fb6/.heroku/go/src/github.com/go-martini/martini (from $GOPATH) 

它工作在我的本地環境和我添加依存關係Godeps/Godeps.jsongodeps save命令。有什麼問題?我注意到官方go-getting-started回購有vendor文件夾,這是否意味着我必須將所有依賴關係放入我的存儲庫?

這是我Godeps/Godeps.json

{ 
    "ImportPath": "github.com/mikamikuh/oauth2-server-tester", 
    "GoVersion": "go1.6", 
    "GodepVersion": "v74", 
    "Deps": [ 
     { 
      "ImportPath": "github.com/codegangsta/inject", 
      "Comment": "v1.0-rc1-10-g33e0aa1", 
      "Rev": "33e0aa1cb7c019ccc3fbe049a8262a6403d30504" 
     }, 
     { 
      "ImportPath": "github.com/go-martini/martini", 
      "Comment": "v1.0-185-gc257c41", 
      "Rev": "c257c412d547ac70fcaf5596c1a50a7cb832c1fc" 
     } 
    ] 
} 

回答

3

是的,你確實需要都依賴到你的資料庫。

事實上,當您運行godep save ./...並且您使用的是go 1.5或更高版本時,Godep會自動將依賴項放入名爲vendor(位於您的repo的根目錄內)的目錄中。您需要將Godep和vendor目錄提交到存儲庫。

在添加供應商目錄的同時請注意使用-f標誌來添加其中的所有文件。這是需要的,因爲某些文件/目錄可能不會提交,具體取決於您的gitignore文件,這會導致heroku中的構建失敗。作爲標準實踐,您可以在使用godep添加依賴項後執行以下命令。

混帳添加-f供應商/ Godep/

git的承諾-a -m 「Vendorizing依賴」

相關問題