Hi everybody,I'm new to this list so I hope I'm not going to post something that doesn't belong here. :-)A little bit of contextI'm trying to run a small Go Web server on Heroku. When I try to import anything a module outside of my web server package, it fails to compile on heroku.Basically my directory structure is:/src//src/okvivi/gofe//src/okvivi/models/In src/okvivi/gofe/gofe.go I have a statement to import "okvivi/models".My problemThe code compiles fine locally, but when I try to push it to heroku, I get the following error:$ git push heroku masterCounting objects: 14, done.Delta compression using up to 8 threads.Compressing objects: 100% (8/8), done.Writing objects: 100% (14/14), 1.25 KiB, done.Total 14 (delta 0), reused 3 (delta 0)-----> Fetching custom git buildpack... done-----> Go app detected-----> Installing Go 1.0.3... doneInstalling Virtualenv... doneInstalling Mercurial... doneInstalling Bazaar... done-----> Running: go get -tags heroku ./...package okvivi/models: unrecognized import path "okvivi/models"! Heroku push rejected, failed to compile Go appTo g...@heroku.com:gofe-example.git! [remote rejected] master -> master (pre-receive hook declined)error: failed to push some refs to 'g...@heroku.com:gofe-example.git'I've set this up as a simple skeleton to see the error and I've put it here on github https://github.com/okvivi/go-server-on-heroku.I've added the error and the steps to reproduce in the README.Does anybody know if I'm doing something wrong, or whether I should start debugging the buildpack?Maybe somebody that's set up Go on Heroku successfully can see if I'm doing anything trivially wrong?Thanks,Octavian.
First, it has two binaries which compile fine, but only because all the code necessary for each binary is in one place only, and there's no code split into multiple packages that each of those binaries need.Second, the moment you try to split that code into packages it doesn't compile locally anymore because the code is not organized according to Go standards of having to have the code under a GOPATH/src directory where the Go compiler knows how to look for libraries and packages.Third, code organization in the go-heroku-example repository there has no concept of packages all together - web.go is in the root of the repository - which is not reflective of real world development where once you have a reasonable amount of code you start needing to split it across packages so you can share code among binaries.
+------ .godir is this ---------+
| |
v v
$GOPATH/src/github.com/kr/go-heroku-example/.git <-- git repository root is here|+binary.go
|
+library/code.go|
+worker/other_binary.go
+- .git root here
|
v
/work/git-repo/go/src/foobar/server/binary.go^ ^ | |
| | | +worker/worker_binary.go
+----$GOPATH-----+ | |
| +shared/code.go|
|
and then do something like this:+.godir <- empty file here.
I use this kind of strange structure because our repository is home to all binaries and code that we have, all in one place.$ git subtree push --prefix go/src heroku master
> +------ .godir is this ---------+
--Thanks for this post. That was the moment that clicked for me.I'll also admit I had a hard time understanding the buildpack convention, particularly because it doesn't quite follow a standard go workspace as defined here:I created a standard go workspace and symlinked the second-level packages such that the go buildpack can find them. I also created a pull request to merge into your project: https://github.com/okvivi/go-server-on-heroku/pull/1Hope that helps,Adam
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/6tyCz7Tc8Ow/unsubscribe?hl=en-US.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.