Go plugin debugging

Viewed 439

There is a golang application that loads the plugin at runtime. I am developing this plugin and I would like to ask if there is an opportunity to debug the code of my plugin?

I tried to run delve by compiling both the application and the plugin with --gcflags="all=-N -l", but running the application in the debugger I got an error the executable file does not contain debugging information for the plugin

Are there ways to debug golang plugin?

1 Answers

Solution: put breakpoint via runtime.Breakpoint(), then run application with delve. It will stop on breakpoint at the plugin code.

Don't forget to build plugin and application with flags: go build -trimpath -gcflags "all=-N -l"

Related