This issue found when you are compiling go plugins on Apple MAC M1 (silicon chips). time="Mar 29 17:22:28" level=error msg="Could not load Go-plugin" error="plugin.Open("plugins/go/example/example-go-plugin.so"): /opt/tyk-gateway/plugins/go/example/example-go-plugin.so: cannot open shared object file: No such file or directory" mwPath="plugins/go/example/example-go-plugin.so" mwSymbolName=AddHelloWorldHeader Seems we have some CPU architecture compiling issues for M1, need to force Gateway image to be amd/64 -Delete Existing Gateway docker image:
docker images | grep gateway
docker image rm <gateway-image-id>
-Pull the amd/64 specific gateway image version
DOCKER_DEFAULT_PLATFORM=linux/amd64 docker pull tykio/tyk-gateway:v<gateway-version>
The error plugin already loaded indicates that a plugin with the same ID is already loaded. This can happen when same compiled plugin .(so) file you are using in two different API, even you rename it later and use or change the path where it is placed in gateway . 'level=error msg="Could not load Go-plugin" error="plugin.Open(\"./middleware/CustomGoPlugin-lt.so\"): plugin already loaded (previous failure)" mwPath=./middleware/CustomGoPlugin-lt.so mwSymbolName=AuthCheck' It is recommended to compile plugin with different function name if you want to use them at multiple place. docker run --rm -v pwd:/plugin-source tykio/tyk-plugin-compiler:v5.0.0 plugin1.so docker run --rm -v pwd:/plugin-source tykio/tyk-plugin-compiler:v5.0.0 plugin2.so Even after compiling plugin with different function name can cause this error if your .go file is using init() and you have some variable initialization in the init() method, and the variable names are the same in the two plugins. A Golang plugin as a package can have
func init()and it gets called only once (when Tyk loads this plugin for the first time for an API). If you prefer to use the same function name for both plugins, then you must use different variable names in the init() method.