herokugogodeps

Godep processing custom packages


Here's my problem. I have go-app which uses some custom packages I created by myself. I don't want to publish this packages on git or elsewhere. They're just packages with some certain functionality.

So, my project folder looks like this:

|--src/github/u-mulder
  |--/project_name
       |--/Godeps  
       |--/public
       |--/vendor
       |--main.go  
       |--Procfile  

I place my packages to vendor folder:

-/Godeps  
-/public
-/vendor
  |---/github.com/u-mulder/package_one/package_one.go
  |---/github.com/u-mulder/package_two/package_two.go
-main.go  
-Procfile  

Okay, in my main.go I successfully import this packages:

import (
    "database/sql"
    "fmt"
    "github.com/u-mulder/package_one"
    "github.com/u-mulder/package_two"
    // more packages here    
)

And everything works fine.

Now I want to prepare my project for deploying to heroku using godep. So, in a root folder of my project I run

> godep save ./...

And here comes my problem - as my packages are already in a vendor folder, I receive error:

godep: Package (github.com/u-mulder/package_one) not found

Sure, I can create a project for every of my packages. Then the structure of src will look like:

|--src/github/u-mulder
  |--/package_one
    |-package_one.go
  |--/package_two
    |-package_two.go
  |--/project_name
       |--/Godeps  
       |--/public
       |--/vendor
       |--main.go  
       |--Procfile  

Then the above mentioned problem is gone, but the second one appears:

godep: error while inspecting "$GOPATH/src/github.com/u-mulder/package_one": directory "$GOPATH/src/github.com/u-mulder/package_one" is not using a known version control system

So, of course I can create a .git repository in each project package (and maybe this problem will be gone), but I don't want, these are just local packages for my use only.

So, the question is - where to place my custom (or say - local) packages so godep can find them and don't want them to be "real" packages?

Something similar I found here, but it's not about vendor folder.


Solution

  • Thanks to @JimB comments I found out the following:

    the most obvious and simple solution is just

    keep your dependencies in GOPATH, with version control, and just let godep handle them all (@JimB)

    So yes, this means adding package(s) to git and all this stuff.

    In case if you don't want/can't do that, the order of actions can be:

    But obvioulsy it is not a good way.