Can plugins be used across repositories?

58 views
Skip to first unread message

Sean Russell

unread,
Feb 29, 2020, 11:04:29 AM2/29/20
to golang-nuts
Has anyone had any success using plugins across repositories using Go modules?

I have two github repositories; one uses plugins (USER), the other contains a plugin (USED).  I have a tag on a commit in the USER repo, and the go.mod in the USED repo references that version.  Both go.mod files reference the same Go version.

If I modify the USED go.mod to include a replace rule for the USED repository so that it's pointing to a relative clone, the module works fine.  If I try to build both from the remote source, it does not.  I'm trying to figure out if there's a step I'm missing, or if this isn't yet possible.  The error I get is the usual:
plugin was built with a different version of package github.com/xxxserxxx/gotop/v3/devices
Steps I'm using (that fail -- this won't work right now because I've made commits past the tagged version)
  1. go get -u github.com/xxxserxxx/gotop/cmd/gotop
  2. go build --buildmode=plugin -o dummy.so .
  3. Also: git checkout v3.4.3 && go build -o gotop ./cmd/gotop produces binaries that are not compatible with the previous step.  This, I'd expect to work as they're the exact same tagged versions.
Step 1 is run outside of the plugin directory, to avoid any issues with go get unnecessarily modifying the cwd go.mod

I've also run go clean -i -r -x -cache -modcache in $HOME and both clones to (try to) ensure there's no accidental grabbing of the wrong version.

I do understand the caveats about the early and non-production-ready status of plugins.  I'd love to hear if anybody is building using go modules directly from a github repository successfully, and what they're doing to make it work.

Thank you


TMI:
Main go.mod:
module github.com/xxxserxxx/gotop/v3

require (
  // SNIPPED for brevity-- there are no shared referenced dependencies
)

go 1.14

dummy go.mod (in its entirety):

Reply all
Reply to author
Forward
0 new messages