example plugin for Kubo
This repository contains a set of example Kubo plugins, demonstrating how to integrate external plugins into Kubo.
Packages:
NOTE 1: Plugins only work on Linux and MacOS at the moment. You can track the progress of this issue here: https://github.com/golang/go/issues/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.
Go plugin system is very whiny. The following constellation need to align:
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:
go get github.com/ipfs/kubo@<version>
boxo
, datastore
and other dependencies are aligned with the version of Kubo. Otherwise set the right versions manually.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.
This is more tricky.
-trimpath
when doing go build
(i.e. go build -trimpath
)-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.
Feel free to join in. All welcome. Open an issue!
This repository falls under the IPFS Code of Conduct.
MIT