Skip to content

Instantly share code, notes, and snippets.

@saml
Last active January 28, 2016 17:00
Show Gist options
  • Save saml/f1001b9a58b5f856d2fe to your computer and use it in GitHub Desktop.
Save saml/f1001b9a58b5f856d2fe to your computer and use it in GitHub Desktop.

Given pkg foo:

github.com/saml/foo/
  src/
    saml/
      foo/
        a.go
  .gocfg/
    gopaths
    vendor.json
  vendor/
    src/
      ...

I want to use the package foo in other project, bar. I want wgo to get package foo under bar's vendor/src/saml/foo like the following:

github.com/saml/bar/
  src/
    saml/
      bar/
        b.go
  .gocfg/
    gopaths
    vendor.json
  vendor/
    src/
      saml/
        foo/
          a.go

So that bar/b.go can do:

import "saml/foo"

Even if I write bar/.gocfg/vendor.json as:

{
  "GitRepos": {
    "vendor/src/saml/foo": {
      "URI": "https://github.com/saml/foo/src",
      "Ref": "fbf0b2e524306408014c325db63e22749a14319b"
    }
  },
  "MercurialRepos": {}
}

I can't wgo restore:

restoring "/home/saml/go/src/github.com/saml/bar/vendor/src/saml/foo":
Cloning into '/home/saml/go/src/github.com/saml/bar/vendor/src/saml/foo'...
fatal: repository 'https://github.com/saml/foo/src/' not found

How can I have wgo restore to clone github.com/saml/foo somewhere and put its src/ directory to vendor/src/saml/foo ?

I can solve this if I write package foo as:

github.com/saml/foo/
  a.go
  ...

instead of putting source (a.go) under src/saml/foo/. And, changing bar's vendor.json to:

{
  "GitRepos": {
    "vendor/src/saml/foo": {
      "URI": "https://github.com/saml/foo",
      "Ref": "fbf0b2e524306408014c325db63e22749a14319b"
    }
  },
  "MercurialRepos": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment