Go project with third party packages on Heroku - heroku

When deploying a Go project to Heroku, installation of the pq package fails. I've posted this in heroku buildpack github issues as well.
Error at deploy time:
-----> Running: godep go install -tags heroku ./...
gournay.go:10:3: cannot find package "github.com/lib/pq" in any of:
/app/tmp/cache/go1.2.1/go/src/pkg/github.com/lib/pq (from $GOROOT)
/tmp/build_ce268203-801e-4dfc-a56c-d70698d6c5bf/.heroku/g/src/github.com/andyatkinson/gournay/Godeps/_workspace/src/github.com/lib/pq (from $GOPATH)
/tmp/build_ce268203-801e-4dfc-a56c-d70698d6c5bf/.heroku/g/src/github.com/lib/pq
godep: go exit status 1
go get and go install run locally as expected. The project is built and running locally. I believe my package structure is correct, and GOPATH and GOROOT are correct. I am using godep which creates the dependencies file below. The source for the pq package appears to be copied into the project, so it seems like it would compile from that source.
~/go/src/github.com/andyatkinson/gournay (master) $ cat Godeps/Godeps.json
{
"ImportPath": "github.com/andyatkinson/gournay",
"GoVersion": "go1.2.1",
"Deps": [
{
"ImportPath": "github.com/lib/pq",
"Rev": "c808a1bb644594ca717ac61f71e6b0e454b835e2"
}
]
}
Am I missing something? Anything else I should check? Thanks!

Do you run godep save on development?
from godep README:
$ godep save
This will save a list of dependencies to the file Godeps/Godeps.json,
and copy their source code into Godeps/_workspace. Read over its
contents and make sure it looks reasonable.
Then commit the file to version control.
--- UPDATE ---
I see your repo, and up on heroku http://warm-depths-3154.herokuapp.com/, follow the steps
rm -Rf gopack.config .godir .gopack
godep save
git add --all . // please commit the Godep folder
git commit -m 'using godep, removed gopack'
(the commit https://github.com/dukex/gournay/commit/0de2390835357879a34ea452a56eeeb6391e5ba8)

Related

Godep save deletes all deps in vendor and godep update

Im pretty new to Go but not to software. Im working on a new team with lots of projects and dependencies so we must use godep.
All the code is structure in the standard Go way, with files in $GOPATH/.../github.com/... etc (including our work which is in github)
I made changes to project A (github.com/ourTeam/A) and I want to run project B (github.com/ourTeam/B) which references A to test my code.
so I commit my work from A in my own branch in A, (and even pushed the branch).
-> All I want is to update B with my new version of A.
From B, I tried:
godep update github.com/A/subpackage. It said 'godep: no packages can be updated'
godep save. It deleted EVERYTHING in the vendor folder, leaving the Godeps.json file empty from any dependencies
manually updating Godeps.json with my commit, then running godep update.
No message but it didnt update anything. Godep save after this change deleted everything too in the vendor folder and Godep.json
What am I missing ?
Note: Im using godep v65 (darwin/amd64/go1.6.2) and godep save -v said
godep: Finding dependencies for [.]
godep: Found package: github.com/ourTeam/B
godep: Deps:
(nothing so the diff with old file removes everything)
The error message when you tried to update tells me that the dependency on A had not been godep-saved before in B. That would mean you need to save it, instead of updating.
Today, I was having the same problem as you using godep save. All dependencies were being removed. However, this got me through it:
$ go get -u github.com/tools/godep # Make sure you have the latest godep (currently v71)
$ godep save ./... # Literally, "./..." is the argument
# The above command may fail with "Package not found ..."
# Install any package not found with "go get some/package/path"
$ go get some/package/path # if necessary
# Try "godep save ./..." again; repeat "go get" for any "not found" errors.
Once godep save returned without errors, I checked and it had done as expected. It only added the new dependency I had imported in the code.

Godeps development flow?

Bit confused with Godeps in general. Say I'm contributing Go code to a central repository, and now I need to pull the code and contribute my own code changes. What would be the correct godep flow?
Would it be:
git pull // pull latest master
godep restore // Install the package versions specified in Godeps/Godeps.json to $GOPATH
go get foo/bar // Get package foo/bar and edit your code to import foo/bar
godep save ./... // Saves dependencies
// Then, check into source control
One option:
git pull
godep restore
go get -u foo/bar // -u updates
go test ./...
go run main.go
godep save ./...
But, I don't like restoring to my GOPATH in disconnected HEAD states of git, since I contribute to several other repos (and have gotten errors in the past with this) directly within my GOPATH.
So I usually do this:
git pull
go get -u foo/bar
godep update foo/bar
godep go test ./...
godep go run main.go
Using godep as a prefix changes the $GOPATH for go-related functions.
TIP: set all the flags of your main executable with sensible defaults, for all developers. That way they don't need to pass custom parameters just for local development.

Terraform - Process to Update vendor aws-sdk-go dependencies to latest

Hi I am trying to understand as how to update the aws-sdk-go dependencies for terraform. To do this i have configured the
GOPATH as per instruction given below.
http://www.wadewegner.com/2014/12/easy-go-programming-setup-for-windows/
I have installed and configured "godep" in $path.
So now i am able to run "go" and "godep" from cmd.
as per development terraform section\guideline given at
https://github.com/hashicorp/terraform i have git cloned
it at $GOPATH/src/github.com/hashicorp/terraform
again as per guideline i just want to update aws-sdk-go deps. so i am running
godep update github.com\aws\aws-sdk-go
getting below message on cmd
godep: not in manifest: github.com\aws\aws-sdk-go
godep: Package (github.com/Azure/azure-sdk-for-go/Godeps/_workspace/src/github.com/Azure/go-autorest/autorest) not found
I have also verified that path
D:\Ampush\Projects\GO\src\github.com\hashicorp\terraform\vendor\github.com\Azure\azure-sdk-for-go\Godeps\_workspace\src\github.com\Azure\go-autorest\autorest
exists on my machine.
I am running command from below path
D:\Ampush\Projects\GO\src\github.com\hashicorp\terraform>
Updating this further with more findings
if i run first godep restore -v then it has downloaded many stuffs.
then i figured out that my command was wrong now i updated it to
godep update github.com/aws/aws-sdk-go/aws //hint saw in Godep.json
Now i am getting
godep: no packages can be updated
i guess that somewhere i have to mention as to which version i should update default i was assuming it will take latest from the master.
Could you please let me know if i am missing something. Thanks
godep update will update the vendored version from your global gopath version. To get the latest version in your gopath run something like go get -u github.com/aws/aws-sdk-go then you can run your godep update

godep save ./... seems not working for https://github.com/hashicorp/terraform

Hi i am following the link https://github.com/hashicorp/terraform . As per given section "Adding a dependency" i have successfully run below commands
git checkout master
git pull
godep restore -v # flag is optional, enables verbose output
git checkout my-feature-branch
git rebase master
Now when i run
godep save ./...
i am getting few packages not found.
if i manually update this package with go get then it looks another one and so on..
Please let me know how can i run this successfully thanks
godeps requires the dependencies to be already in your GOPATH. If you haven't downloaded the dependencies (yet), first run
go get ./...
Then you can run
godep save ./...

golang and godep : Build\install after a golang dependency update when using godep?

I have followed the instructions # https://github.com/tools/godep regarding updating a dependency but when I go to build\install using the altered version it has not been updated within Godeps/_workspace/pkg
So I have
go get github.com/golang/glog
godep save
godep go install
and I can see
The modification timestamp in Godeps/_workspace/pkg/linux_amd64/github.com/golang/glog.a
The rev commit value in Godeps/Godeps.json
but now when I want to update I follow the instructions
go get github.com/golang/glog
godep update github.com/golang/glog
godep go install
I observe the following
The Godeps/Godeps.json rev commit has been updated
Godeps/_workspace/src/github.com/golang/ source is updated
But the file timestamp for odeps/_workspace/pkg/linux_amd64/github.com/golang/glog.a is not updated hence we are using the previous version
I believe I should add a .gitignore entry for pkg and bin, which means we would do a clean build on a fresh git clone
I know I could do a rm -r on both the pkg and bin directories before the godep go install command
Is this expected behavior ?
Thanks in advance
Pat
FYI
Since golang v1.4 I can now use the -a flag for the go install command, since it now longer tries to rebuild the standard library, see the v1.4 release notes section on the change to the build -a flag
Obviously this does not apply in pre v1.4 as it will attempt to rebuild the standard library packages

Resources