77347

Go App On Heroku With Local Packages

I'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?

Answer1:

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:

https://devcenter.heroku.com/articles/go-support#migrating-from-go1-5-godep-workspace-to-go1-6-with-a-vendor-directory

Answer2:

I have a solution that worked for me, though I don't like it, and hope its not the correct way to do it!

I'm using vendor. Both locally and TravisCI were able to build my app, but TravisCI could not deploy it to Heroku, as Heroku was having troubles finding local packages as well. What I ended up doing is fetching local packages with vendor:

govendor fetch +local

Once I committed again, TravisCI built and deployed to Heroku, and my app worked.

The reason I don't like this solution is that I now have duplicate code! My local subpackages can be found in /, as well as in vendor: /vendor/

Recommend

  • Lookup or index-match list between/after string
  • Does boost support serialization of c++11's std::tuple?
  • How to delete log file after a week?
  • How to compare two pdf files? [duplicate]
  • reactjs - fetch as google displays blank page only
  • build-pysnmp-mib: convert cisco mib files to a python fails on Ubuntu 14.04
  • What's the meaning of the ethereum Parity console output lines?
  • JPEGEncoderOptions is undefined
  • Test URLs for SNMP Agents
  • Heroku push hanging on “fetching gem metadata from rubygems” with no errors or trace of any kind
  • Issues with wmode=“opaque” and issues with wmmode=“window”
  • Gerrit will not push. Error: No common ancestry
  • How can I emulate a recursive type definition in C++?
  • Java Garbage collection, setting reference to null
  • In Akka, is ActorContext thread safe?
  • How to retrieve multiple columns from non-entity type sql query?
  • Organizing large javascript files [closed]
  • Refactoring advice: maps to POJOs
  • JavaScriptCore External Arrays
  • Single django queryset to get n adjacent items
  • Unzip archive in .Net CORE 1.0
  • Save image as is in photo album using swift
  • XOR with Neural Networks (Matlab)
  • Double dispatch in Java example
  • conditions for accessors in Coldfusion ORM
  • File extension of zlib zipped html page?
  • Django return user model id with L
  • In Java, how can I construct a File from a resource?
  • git add error : “fatal : malloc, out of memory”
  • Do query loads all the data in memory
  • How to get current document uri in XSLT?
  • SharedPreferences or SQLite Database?
  • Date Conversion from yyyy-mm-dd to dd-mm-yyyy
  • Debug.DrawLine not showing in the GameView
  • Record samples being played with OpenAL
  • How to avoid particles glitching together in an elastic particle collision simulator?
  • CSS Linear-gradient formatting issue accross different browsers
  • Spray.io: When (not) to use non-blocking route handling?
  • Transpose CSV data with awk (pivot transformation)
  • Python/Django TangoWithDjango Models and Databases