-
Notifications
You must be signed in to change notification settings - Fork 0
2. Software
Saman edited this page Oct 8, 2025
·
5 revisions
For Go language, the current debugging tool is Delve. To read more about the debugger and its commands, please visit their GitHub page: https://github.com/go-delve/delve.
We need to add a new port so that our Docker setup connects to the required port. Follow these steps:
- Find the
docker-compose.ymlfile under thedockerdirectory. - Add the following port to the
aisection of this file:ports: - "2345:2345"
- After running the
start.shscript and choosing your module, install Delve by running:go install github.com/go-delve/delve/cmd/dlv@v1.25.0 - Navigate to the
cmddirectory:cd cmd/ - Launch Delve in debug mode:
/go/bin/dlv debug main.go
You now have access to the terminal version of Delve where you can set breakpoints and inspect variables.
- Ensure the port has been added as stated above
- After running the
start.shscript and choosing your module, run the following commands:go install github.com/go-delve/delve/cmd/dlv@latest cd cmd/ /go/bin/dlv debug main.go --headless --listen=0.0.0.0:2345 --api-version=2 --accept-multiclient --log
- Open VS Code, install the go package, set your breakpoints
- Press
Ctrl + Shift + D - A new page should appear asking to create a
launch.jsonfile. Click on it, and add the following content to yourlaunch.json:{ "version": "0.2.0", "configurations": [ { "name": "Attach", "type": "go", "request": "attach", "mode": "remote", "remotePath": "", "port": 2345, "host": "127.0.0.1", "showLog": true, "trace": "log", "logOutput": "rpc" } ] }
- Press Run and Debug. MAKE SURE YOUR VSCODE IS RUNNING FROM CONTROLLER DIRECTORY!!!