Go auth plugin example with latest tyk version v4.0.4

I am getting this error while compiling a simple auth plugin

cannot use key (variable of type string) as bool value in argument to ctx.SetSession

I used these steps to compile plugins and these steps have been tested with non-auth plugins (even compilation of auth plugin work if I replace ctx.SetSession(r, session, key, true) with ctx.SetSession(r, session, true, true) but this isn’t right since session isn’t created/cached in Redis):

rm -rf go.mod go.sum vendor/
go mod init tyk-plugin
go mod edit -replace github.com/jensneuse/graphql-go-tools=github.com/TykTechnologies/[email protected]
go get github.com/TykTechnologies/[email protected]
<Write and finalize code>
go mod tidy
go mod vendor
docker container run -v $(pwd):/plugin-source --rm tykio/tyk-plugin-compiler:v4.0.4 plugin.so

I think we should update GitHub - TykTechnologies/custom-plugins: Custom plugin examples for the Tyk Gateway - if you ever needed to extend the functionality! and docs to support latest version of tyk.


Hey @armujahid,

Thanks for posting this here. I’ve created an internal ticket to this end.

1 Like