Giter Site home page Giter Site logo

go-ipfs-example-plugin's Introduction

go-ipfs-example-plugin

standard-readme compliant GoDoc

example plugin for Kubo

This repository contains a set of example Kubo plugins, demonstrating how to integrate external plugins into Kubo.

Packages:

  • delaystore: an example datastore plugin that wraps an inner datastore in a "delayed" datastore.
  • greeter: an example daemon plugin that prints "Hello!" on start and "Goodbye!" on exit.

NOTE 1: Plugins only work on Linux and MacOS at the moment. You can track the progress of this issue here: golang/go#19282. MacOS users will need to compile Kubo themselves too, as official MacOS releases of Kubo are cross-compiled and do not support loading plugins. Also, only amd64 architecture is supported.

NOTE 2: This plugin exists as an example and a starting point for new plugins. It isn't particularly useful by itself.

Building and Installing

Go plugin system is very whiny. The following constellation need to align:

  • You need to be using the same Go version to compile Kubo and the plugin. Upstream releases of Kubo use whatever it says here (v0.19.10) at the time of writing.
  • The dependencies in go.mod need to be exactly the same as in the Kubo version that we want the plugin to work with. In this example, the following need to be the same as in Kubo's go.mod:
    • github.com/ipfs/boxo
    • github.com/ipfs/go-datastore
    • github.com/ipfs/go-ipfs-delay
    • github.com/ipfs/kubo
  • There are additional consideration with -trimpath etc (see below).
  • Failure to do so will cause errors when loading the plugin.

Using official Kubo releases

As provided the plugin is designed to work with a default version (whatever is used in the go.mod file). You can use:

make build
make install

to build and install this version.

If you want to upgrade or use a different official release of Kubo:

  1. go get github.com/ipfs/kubo@<version>
  2. Verify boxo, datastore and other dependencies are aligned with the version of Kubo. Otherwise set the right versions manually.
  3. go mod tidy.

In some cases, fully removing the second, "indirect requires" block in go.mod and running go mod tidy will fix wrong indirect requires.

Using local Kubo builds

This is more tricky.

  1. Ensure full dependency alignment
  2. If you are building Kubo somewhere else (on a different computer), ensure it is built using -trimpath when doing go build (i.e. go build -trimpath)
  3. You may need to build the plugin using -trimpath or not, depending on how you are building the Kubo binary and where. i.e. you can use a replace directive in go.mod to point to a local version of Kubo and then it is possibly fine to build the plugin and Kubo without trimpath altogether.

If Go versions and dependencies are aligned, usually errors have to do with -trimpath stuff. You can also try -asmflags=all=-trimpath="$(GOPATH)" -gcflags=all=-trimpath="$(GOPATH)" and setting $(GOPATH) to what go env says etc. and try to get both the plugin and Kubo binaries to reference modules with exactly the same paths.

Contribute

Feel free to join in. All welcome. Open an issue!

This repository falls under the IPFS Code of Conduct.

Want to hack on IPFS?

License

MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.