Using go-ipfs as a library: problems with dep

Hi there – I’d like to use go-ipfs as a library in a small CLI tool that I’m building to demo IPFS’s pubsub functionality. I’m using the “official” go dependency management tool dep to manage dependencies for my app and when I try to run dep init it complains about problematic subpackages (it’s a pretty long stacktrace, but here’s a gist):

        sharding-pre: Could not introduce github.com/jbenet/go-ipfs@sharding-pre due to multiple problematic subpackages:
        Subpackage github.com/jbenet/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context is missing. (Package is required by github.com/ipfs/go-ipfs@v0.2.2-buildfails.)     Subpackage github.com/jbenet/go-ipfs/p2p/crypto is missing. (Package is required by github.com/ipfs/go-ipfs@v0.2.2-buildfails.) Subpackage github.com/jbenet/go-ipfs/p2p/net/swarm/addr is missing. (Package is required by github.com/ipfs/go-ipfs@v0.2.2-buildfails.)     Subpackage github.com/jbenet/go-ipfs/routing does not contain usable Go code (*build.NoGoError).. (Package is required by github.com/ipfs/go-ipfs@v0.2.2-buildfails.)   Subpackage github.com/jbenet/go-ipfs/thirdparty/eventlog is missing. (Package is required by github.com/ipfs/go-ipfs@v0.2.2-buildfails.)    Subpackage github.com/jbenet/go-ipfs/util is missing. (Package is required by github.com/ipfs/go-ipfs@v0.2.2-buildfails.)       Subpackage github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-ctxgroup is missing. (Package is required by github.com/ipfs/go-ipfs@v0.2.2-buildfails.)    Subpackage github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/keytransform is missing. (Package is required by github.com/ipfs/go-ipfs@v0.2.2-buildfails.)  Subpackage github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net is missing. (Package is required by github.com/ipfs/go-ipfs@v0.2.2-buildfails.)       Subpackage github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess/context is missing. (Package is required by github.com/ipfs/go-ipfs@v0.2.2-buildfails.)      Subpackage github.com/jbenet/go-ipfs/p2p/host is missing. (Package is required by github.com/ipfs/go-ipfs@v0.2.2-buildfails.)   Subpackage github.com/jbenet/go-ipfs/util/debugerror is missing. (Package is required by github.com/ipfs/go-ipfs@v0.2.2-buildfails.)    Subpackage github.com/jbenet/go-ipfs/util/testutil is missing. (Package is required by github.com/ipfs/go-ipfs@v0.2.2-buildfails.)  Subpackage github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore is missing. (Package is required by github.com/ipfs/go-ipfs@v0.2.2-buildfails.)       Subpackage github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess/periodic is missing. (Package is required by github.com/ipfs/go-ipfs@v0.2.2-buildfails.)     Subpackage github.com/jbenet/go-ipfs/p2p/protocol/identify is missing. (Package is required by github.com/ipfs/go-ipfs@v0.2.2-buildfails.)      Subpackage github.com/jbenet/go-ipfs/routing/dht is missing. (Package is required by github.com/ipfs/go-ipfs@v0.2.2-buildfails.)    Subpackage github.com/jbenet/go-ipfs/util/datastore2 is missing. (Package is required by github.com/ipfs/go-ipfs@v0.2.2-buildfails.)    Subpackage github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/braintree/manners is missing. (Package is required by github.com/ipfs/go-ipfs@v0.2.2-buildfails.)     Subpackage github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-base58 is missing. (Package is required by github.com/ipfs/go-ipfs@v0.2.2-buildfails.)  Subpackage github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/fs is missing. (Package is required by github.com/ipfs/go-ipfs@v0.2.2-buildfails.)        Subpackage github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/opt is missing. (Package is required by github.com/ipfs/go-ipfs@v0.2.2-buildfails.)      Subpackage github.com/jbenet/go-ipfs/p2p/peer is missing. (Package is required by github.com/ipfs/go-ipfs@v0.2.2-buildfails.)       Subpackage github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/leveldb is missing. (Package is required by github.com/ipfs/go-ipfs@v0.2.2-buildfails.)       Subpackage github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess is missing. (Package is required by github.com/ipfs/go-ipfs@v0.2.2-buildfails.)      Subpackage github.com/jbenet/go-ipfs/p2p/host/basic is missing. (Package is required by github.com/ipfs/go-ipfs@v0.2.2-buildfails.)     Subpackage github.com/jbenet/go-ipfs/p2p/net is missing. (Package is required by github.com/ipfs/go-ipfs@v0.2.2-buildfails.)        Subpackage github.com/jbenet/go-ipfs/p2p/net/mock is missing. (Package is required by github.com/ipfs/go-ipfs@v0.2.2-buildfails.)       Subpackage github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr is missing. (Package is required by github.com/ipfs/go-ipfs@v0.2.2-buildfails.)   Subpackage github.com/jbenet/go-ipfs/p2p/net/swarm is missing. (Package is required by github.com/ipfs/go-ipfs@v0.2.2-buildfails.)      Subpackage github.com/jbenet/go-ipfs/util/eventlog/loggables is missing. (Package is required by github.com/ipfs/go-ipfs@v0.2.2-buildfails.)        Subpackage github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync is missing. (Package is required by github.com/ipfs/go-ipfs@v0.2.2-buildfails.)  Subpackage github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash is missing. (Package is required by github.com/ipfs/go-ipfs@v0.2.2-buildfails.)   Subpackage github.com/jbenet/go-ipfs/p2p/host/routed is missing. (Package is required by github.com/ipfs/go-ipfs@v0.2.2-buildfails.)

Is there a recommended way of using go-ipfs as a lib dependency in another Go project? Should I be compiling go-ipfs first before trying to include it?

Hah, I just made a go-ipfs fork that plays nice with go get and govendor https://github.com/ipsn/go-ipfs :smiley:

Unfortunately dep still chokes on it, displaying an error that to me at least seems like a bug in dep. Will submit a bug report to them about it. In the mean time, take this repo for a spin and tell me what you think :wink:

2 Likes

Wow thanks for doing this! It’s crazy that we can’t use go-ipfs as a standard dependency in a go project – was almost tempted to use the JS library instead because that seems to be a regular npm module. But will give it a try with this – can you share what command you use to un-gx the repo? In the future I’d like to pin to a specific version of ipfs/go-ipfs

I wrote my own tool after I couldn’t find anything remotely suitable for the task: GitHub - karalabe/ungx: gx is a powerful package management tool... ungx gets rid of it :D. It’s fairly well documented as to what it does and why.

The repo that I linked in my previous post is automatically updated via Travis cron jobs everynight, you can find the build script in the ungx branch: https://github.com/ipsn/go-ipfs/blob/ungx/.travis.yml.

I also have it planned to retroactively ungx all the past releases and tag them in my fork, but that’s a one time operation (you can’t just retag code), so first I want to ensure that the ungx procedure works correctly before I lock the tags in.

Awesome thanks, btw – found this that will probably help in getting a specific version including all of the dependencies: https://github.com/ipfs/go-ipfs/pull/4920