GoLand
The DebugHero plugin adds a DebugHero tool window to GoLand. From this tool window you start sessions, see their status, and connect the GoLand debugger to Delve.
Requirements
debugdruns on your machine. See Your first debug session. Ifdebugddoes not run, the tool window shows "debugd isn't running" and a Retry button.
Sign in
- Open the DebugHero tool window.
- Select Sign In. Your browser opens the sign-in page.
You can also run the action DebugHero: Login.
The plugin stores its credentials in the GoLand password safe. debugctl stores its credentials in the OS keychain. Sign in to each one separately.
Start a session
-
In the DebugHero tool window, select New Debug Session.
-
Enter the values of the target pod:
Field Required Description Pod labels Yes A label selector, for example app=checkout. DebugHero uses the first pod that matches.Namespace No Default: default.Container name No Default: the first container of the pod. Match process name No Text to find the target process. Default: PID 1. App port No An application port to forward to the same port on localhost.Kubeconfig path No A path, or a list of paths separated by :. Prefilled withKUBECONFIGof the IDE, else~/.kube/config, the same askubectl. The form keeps the value you submit. After you changeKUBECONFIG, check this field. -
Select Start Debug Session.
-
The session shows under Running sessions. When it is ready, select Connect.
GoLand starts a Go Remote debug configuration for 127.0.0.1 and the local Delve port of the session. The session card shows "Connected in this project".
To see sessions that ended, select View session history.
Source paths
GoLand maps the paths in the binary to the files of your project automatically. You do not need to set a path mapping. Open the root of the Go module that was built into the image as the project. See Map source paths.
Disconnect and stop
There are two actions. They do different things.
| Action | What it does |
|---|---|
| Disconnect | Closes the connection of GoLand to Delve. The session continues, and Delve stays attached. You can connect again. |
| Stop Session | Ends the session. Delve removes its breakpoints and detaches. The app continues to run. The debug container exits, and the session becomes COMPLETED. You cannot connect again. |
Disconnect
Run the action DebugHero: Disconnect from Remote Debug Pod, or stop the GoLand debug session.
When you disconnect, GoLand shows a reminder: "Disconnected. Session N is still attached to POD." Select Stop session to stop it, or Keep running to keep it. GoLand never stops a session automatically.
If you do not stop the session, it stops automatically after 1 hour.
Stop
- Select Stop Session on the session card in the DebugHero tool window, or run DebugHero: Stop Debug Session from Find Action.
- Confirm the stop.
If GoLand is connected to the session, it disconnects first.
The stop usually takes a few seconds. It can take up to 75 seconds: debugd waits up to 45 seconds for the debug server to shut down, then up to 30 seconds for the debug container to exit. GoLand waits up to 90 seconds for the result.
| Message | What to do |
|---|---|
| The session is still starting | Wait until the session is READY, then try again. |
| The debug container does not answer | Try again. If the problem continues, restart the pod. |
debugd did not answer in time | The stop can still finish. Refresh the session list to see the result. |
| Delve did not detach through its API | The session stopped, but the debug container stopped Delve with a signal. Make sure that the pod still runs. If the app crashed at a breakpoint, restart the pod. |
You can also stop a session from a terminal with debugctl stop.
Settings
Open Settings › Tools › DebugHero.
| Setting | Default | Description |
|---|---|---|
| debugd port | 58090 | The port of debugd. If you change it, also set DEBUG_DAEMON_PORT for debugd. |