This image allows you to debug a go app just creating a volume pointing your app.
The recommended way is to set the session is using docker-compose.
- create a volume mapping the /go/app directory to your project root one.
- map the debugger port, by default is 2345, this can be change by setting the env variable DEBUG_ADDR
- set the security_opt to seccomp:unconfined in order to run the container without the default secure computing mode.
note: while running in debug mode you need to connect the debugger client and your code will start running, you program execution will be blocked if you haven't connect your client.
GoLand
- go to run and select edit configuration and add a new go remote profile.
- set the port if you change it while mapping them, and just run the new configuration.
VS Code
- create a launch.json file
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "attach",
"mode": "remote",
"remotePath": "/go/app",
"port": 2345,
"env": {},
"args": [],
"showLog": true,
"trace": "verbose"
}
]
}
port will be 2345 y default, but if you changed it in the mapping process of the container it needs to be set here.
- go to Run/Start Debugging