How to change Golang version on Tyk 4.x plugin compiler

Hi, I’m using Tyk 4.3.3 and currently developing a plugin. When the plugin is compiled using Tyk’s plugin compiler, it shows some error saying that some packages are not found:

+ go build -buildmode=plugin -o GolangPlugins_v4.3.3_linux_amd64.so
AuthPlugin.go:15:2: cannot find package "github.com/go-jose/go-jose/v3/jwt" in any of:
        /usr/local/go/src/github.com/go-jose/go-jose/v3/jwt (from $GOROOT)
        /go/src/github.com/go-jose/go-jose/v3/jwt (from $GOPATH)
../github.com/pomerium/sdk-go/keystore.go:5:2: cannot find package "github.com/hashicorp/golang-lru/v2" in any of:
        /usr/local/go/src/github.com/hashicorp/golang-lru/v2 (from $GOROOT)
        /go/src/github.com/hashicorp/golang-lru/v2 (from $GOPATH)

after some research, I realized that those packages uses syntax that are only available on Go 1.18 or newer where Tyk’s plugin compiler ver 4.x uses Go version 1.16.15. is there a way to change the golang version on the plugin compiler without upgrading to Tyk 5.x?

Hi,

I’m afraid not. As per https://pkg.go.dev/plugin:

Runtime crashes are likely to occur unless all parts of the program 
(the application and all its plugins) are compiled using exactly the same
version of the toolchain, the same build tags, and the same values of 
certain flags and environment variables.

The gateway is open source so it would be possible to compile it locally and use that compiler to create your plugins however we don’t test the gateway against other golang versions so can’t tell what difference changing the compiler might bring.

I do know there there are changes in the way golang compilers deal with certificate CNs, SANs, expiry dates, default TLS versions so great care would have to be taken testing the resulting gateway binary.

Cheers,
Pete

Got it, thanks for the help!