With some minor modifications to the directions in the Debugging with Delve guide, you can debug your custom Go server runtime code using Delve inside a Docker container via GoLand.
Due to some limitations of the GoLand Debugger, you must install the Dlvx Plugin. To do this, go to GoLand > Settings > Plugins > Search for “Dlvx” > Press Install.
In the Docker Compose file, we add the entrypoint property to the nakama server and set it to run the container using the dlv command. We also add the Delve port (4000) to the ports property.
With the above changes in place, select the Docker Configuration and run it by clicking the start button.
Once Docker finishes the startup, run the Go Remote Configuration:
After the Nakama server is running you can set Go Function Breakpoints and debug from there.
In the following example we have registered an RPC SomeRpc inside the InitModule function.
In order to add a breakpoint, press the red circle right next to the line number you want to add the breakpoint.
After doing this, a faded red circle will appear next to the function name, press that also.
It is currently not possible to add breakpoints to lines of code that are not function signatures using the GoLand’s breakpoint line toggle.
We now need to trigger the RPC. We can do this either by calling it from a client or by visiting the Nakama Console in a browser and using the API Explorer.
Once the RPC has been triggered, you should see that Goland successfully hits the breakpoint and you can now use the standard debugging tools (e.g. Variables, Locals, Step Into, Step Over etc).