# Using go-ipfs as a library: problems with dep

**URL:** https://discuss.ipfs.tech/t/using-go-ipfs-as-a-library-problems-with-dep/2697
**Category:** Help
**Created:** [April 18, 2018, 6:37pm UTC](https://discuss.ipfs.tech/t/using-go-ipfs-as-a-library-problems-with-dep/2697 "2018-04-18T18:37:12Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![arunthampi](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/arunthampi/32/2485_2.png) [@arunthampi](https://discuss.ipfs.tech/u/arunthampi)
#### Post date: [April 18, 2018, 6:37pm UTC](https://discuss.ipfs.tech/t/using-go-ipfs-as-a-library-problems-with-dep/2697/1 "2018-04-18T18:37:13Z")

</div>

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](https://github.com/arunthampi/p2pubsub/blob/sample-ipfs-app/main.go). I’m using the “official” go dependency management tool [dep](https://github.com/golang/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):

```auto
        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?

---

<div class="post-metadata">

### Author: ![karalabe](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/karalabe/32/2475_2.png) [@karalabe](https://discuss.ipfs.tech/u/karalabe)
#### Post date: [April 18, 2018, 9:42pm UTC](https://discuss.ipfs.tech/t/using-go-ipfs-as-a-library-problems-with-dep/2697/2 "2018-04-18T21:42:42Z")

</div>

Hah, I just made a go-ipfs fork that plays nice with `go get` and `govendor` [https://github.com/ipsn/go-ipfs](https://github.com/ipsn/go-ipfs) 😃

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 😉

---

<div class="post-metadata">

### Author: ![arunthampi](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/arunthampi/32/2485_2.png) [@arunthampi](https://discuss.ipfs.tech/u/arunthampi)
#### Post date: [April 24, 2018, 4:22pm UTC](https://discuss.ipfs.tech/t/using-go-ipfs-as-a-library-problems-with-dep/2697/3 "2018-04-24T16:22:57Z")

</div>

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](https://github.com/ipfs/go-ipfs/releases/tag/v0.4.14)

---

<div class="post-metadata">

### Author: ![karalabe](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/karalabe/32/2475_2.png) [@karalabe](https://discuss.ipfs.tech/u/karalabe)
#### Post date: [April 24, 2018, 6:15pm UTC](https://discuss.ipfs.tech/t/using-go-ipfs-as-a-library-problems-with-dep/2697/4 "2018-04-24T18:15:19Z")

</div>

> [@arunthampi](#):
>
> can you share what command you use to un-gx the repo?

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](https://github.com/karalabe/ungx). 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](https://github.com/ipsn/go-ipfs/blob/ungx/.travis.yml).

> [@arunthampi](#):
>
> In the future I’d like to pin to a specific version of ipfs/go-ipfs

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.

---

<div class="post-metadata">

### Author: ![arunthampi](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/arunthampi/32/2485_2.png) [@arunthampi](https://discuss.ipfs.tech/u/arunthampi)
#### Post date: [April 24, 2018, 7:22pm UTC](https://discuss.ipfs.tech/t/using-go-ipfs-as-a-library-problems-with-dep/2697/5 "2018-04-24T19:22:28Z")

</div>

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](https://github.com/ipfs/go-ipfs/pull/4920)
