Trying to build TYK plugins

Trying to import tyk v3.1.2 into my go.mod file plugin like so go get v3.1.2. Obviously now this wouldn’t work due to golang versioning. Tried multiple suggestions found online but none of it seems to work. Some help or direction would be greatly appreciated.

Tyk only started supporting Go mods/vendors as of 3.2.1+

Before that, you would compile your plugin without any dependencies.

Have you tried following this guide for GoLang? Make sure you click the “other” tab as you follow the instructions as the steps have changed starting with v3.2.1

Thank you for the immediate feedback! So slightly related question then when compiling my plugins it automatically uses v2.9.5+incompatible. Is it possible to explicitly import tyk version 3.1.2 during compilation?

Hi Lego,

you can specify the sha1 in the go get command.


The SHA1 for v3.1.2 is 66430f31619e82ec28d1b42e17fb1c9e3688215a

Example, and please don’t forget the go replace call.

$ go mod edit -replace
$ go get

Please report back how this goes for you.

Hi! At the moment you need to use SHA. We not fully have proper Go module versioning yet, and +incompatible is just internal Go comment, that module which you are referring does not support semver versioning. We are planning to address this issue in future releases, but for now using SHA as mentioned by Sedky is a totally valid vay.

Thank you both, and one more question as it’s not obvious to me. How do I go about finding the Sha for each version?

We just updated our Go plugin docs to make it more obvious Golang plugins

So you can find latest plugin instructions for any Tyk version (but 3.1.2 is not there yet, docs versioning was added with 3.2 release).

But manual way is literally checking our github tag, and taking its SHA GitHub - TykTechnologies/tyk at v3.1.2

Hello again, so we’re currently trying to update our golang from 1.12 to 1.15. Since the update our plugins have been throwing an error of "level=error msg=“Could not load Go-plugin” error=“plugin.Open(“plugins/”): plugin was built with a different version of package internal/unsafeheader (previous failure)” mwPath=“plugins/”. Would love to get some more insight on this issue. Thank you.

Side note we are using 3.1.2.

Hi @lego17nav, just following up on the issue. Was Chris’s reply helpful on the new thread Tyk Plugins error when updating golang version - Support - Tyk API Management Community Forum?