# IPFS in Go

# Working with Go

Kubo (go-ipfs) is the oldest implementation of IPFS. It is a command-line application, but can also be used as a library in other Go programs.

For more about using Kubo, see any of the following reference documents:

For more technical information about building, debugging or using the API, see:

If you plan to use Kubo as a package in your own Go application, you can take any of three main approaches:

# Go CoreAPI

CoreAPI interfaces (opens new window) for go-ipfs. Package iface defines IPFS Core API, which is a set of interfaces used to interact with IPFS nodes.

# Go embedded client

Package coreapi (opens new window) provides direct access to the core commands in IPFS. If you are embedding IPFS directly in your Go program, this package is the public interface you should use to read and write files or otherwise control IPFS. This package is experimental and subject to change.

If you are running IPFS as a separate process, you should use go-ipfs-api to work with it via RPC. As we finalize the interfaces in this embedded client, go-ipfs-api will transparently adopt them so you can use the same code with either package.

# Go HTTP clients

CoreAPI implementation using HTTP API (opens new window). This package is experimental and subject to change. For an old but stable Go HTTP client, use CoreAPI interfaces (opens new window).

# Packages

This table is generated using the module package-table (opens new window) with package-table --data=package-list.json.

Listing of the main go packages in the IPFS ecosystem:

Name Go Reference Coverage Description
Libp2p
go-libp2p Go Reference (opens new window) codecov (opens new window) p2p networking library
go-libp2p-pubsub Go Reference (opens new window) codecov (opens new window) pubsub built on libp2p
go-libp2p-kad-dht Go Reference (opens new window) codecov (opens new window) dht-backed router
go-libp2p-pubsub-router Go Reference (opens new window) codecov (opens new window) pubsub-backed router
Multiformats
go-cid Go Reference (opens new window) codecov (opens new window) CID implementation
go-multiaddr Go Reference (opens new window) codecov (opens new window) multiaddr implementation
go-multihash Go Reference (opens new window) codecov (opens new window) multihash implementation
go-multibase Go Reference (opens new window) codecov (opens new window) mulitbase implementation
Files
go-unixfs Go Reference (opens new window) codecov (opens new window) the core 'filesystem' logic
go-mfs Go Reference (opens new window) codecov (opens new window) a mutable filesystem editor for unixfs
go-ipfs-posinfo Go Reference (opens new window) codecov (opens new window) helper datatypes for the filestore
go-ipfs-chunker Go Reference (opens new window) codecov (opens new window) file chunkers
Exchange
go-ipfs-exchange-interface Go Reference (opens new window) codecov (opens new window) exchange service interface
go-ipfs-exchange-offline Go Reference (opens new window) codecov (opens new window) (dummy) offline implementation of the exchange service
go-bitswap Go Reference (opens new window) codecov (opens new window) bitswap protocol implementation
go-blockservice Go Reference (opens new window) codecov (opens new window) service that plugs a blockstore and an exchange together
Datastores
go-datastore Go Reference (opens new window) codecov (opens new window) datastore interfaces, adapters, and basic implementations
go-ipfs-ds-help Go Reference (opens new window) codecov (opens new window) datastore utility functions
go-ds-flatfs Go Reference (opens new window) codecov (opens new window) a filesystem-based datastore
go-ds-measure Go Reference (opens new window) codecov (opens new window) a metric-collecting database adapter
go-ds-leveldb Go Reference (opens new window) codecov (opens new window) a leveldb based datastore
go-ds-badger Go Reference (opens new window) codecov (opens new window) a badgerdb based datastore
Namesys
go-ipns Go Reference (opens new window) codecov (opens new window) IPNS datastructures and validation logic
Repo
go-fs-lock Go Reference (opens new window) codecov (opens new window) lockfile management functions
fs-repo-migrations Go Reference (opens new window) codecov (opens new window) repo migrations
IPLD
go-block-format Go Reference (opens new window) codecov (opens new window) block interfaces and implementations
go-ipfs-blockstore Go Reference (opens new window) codecov (opens new window) blockstore interfaces and implementations
go-ipld-format Go Reference (opens new window) codecov (opens new window) IPLD interfaces
go-ipld-cbor Go Reference (opens new window) codecov (opens new window) IPLD-CBOR implementation
go-ipld-git Go Reference (opens new window) codecov (opens new window) IPLD-Git implementation
go-merkledag Go Reference (opens new window) codecov (opens new window) IPLD-Merkledag implementation (and then some)
Commands
go-ipfs-cmds Go Reference (opens new window) codecov (opens new window) CLI & HTTP commands library
go-ipfs-files Go Reference (opens new window) codecov (opens new window) CLI & HTTP commands library
go-ipfs-api Go Reference (opens new window) codecov (opens new window) an old, stable shell for the IPFS HTTP API
go-ipfs-http-client Go Reference (opens new window) codecov (opens new window) a new, unstable shell for the IPFS HTTP API
interface-go-ipfs-core Go Reference (opens new window) codecov (opens new window) core go-ipfs API interface definitions
Metrics & Logging
go-metrics-interface Go Reference (opens new window) codecov (opens new window) metrics collection interfaces
go-metrics-prometheus Go Reference (opens new window) codecov (opens new window) prometheus-backed metrics collector
go-log Go Reference (opens new window) codecov (opens new window) logging framework
Generics/Utils
go-ipfs-routing Go Reference (opens new window) codecov (opens new window) routing (content, peer, value) helpers
go-ipfs-util Go Reference (opens new window) codecov (opens new window) the kitchen sink
go-ipfs-addr Go Reference (opens new window) codecov (opens new window) utility functions for parsing IPFS multiaddrs

# Hands-on examples

There are use-case examples in the ipfs/kubo GitHub repository (opens new window). They're all self-contained projects that let your spin up and test environments quickly. Check them out → (opens new window).

A good starting place is the Use kubo as a library to spawn a node and add a file (opens new window).