Skip to main content

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​

  • debugd runs on your machine. See Your first debug session. If debugd does not run, the tool window shows "debugd isn't running" and a Retry button.

Sign in​

  1. Open the DebugHero tool window.
  2. 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​

  1. In the DebugHero tool window, select New Debug Session.

  2. Enter the values of the target pod:

    FieldRequiredDescription
    Pod labelsYesA label selector, for example app=checkout. DebugHero uses the first pod that matches.
    NamespaceNoDefault: default.
    Container nameNoDefault: the first container of the pod.
    Match process nameNoText to find the target process. Default: PID 1.
    App portNoAn application port to forward to the same port on localhost.
    Kubeconfig pathNoA path, or a list of paths separated by :. Prefilled with KUBECONFIG of the IDE, else ~/.kube/config, the same as kubectl. The form keeps the value you submit. After you change KUBECONFIG, check this field.
  3. Select Start Debug Session.

  4. 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.

ActionWhat it does
DisconnectCloses the connection of GoLand to Delve. The session continues, and Delve stays attached. You can connect again.
Stop SessionEnds 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​

  1. Select Stop Session on the session card in the DebugHero tool window, or run DebugHero: Stop Debug Session from Find Action.
  2. 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.

MessageWhat to do
The session is still startingWait until the session is READY, then try again.
The debug container does not answerTry again. If the problem continues, restart the pod.
debugd did not answer in timeThe stop can still finish. Refresh the session list to see the result.
Delve did not detach through its APIThe 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.

SettingDefaultDescription
debugd port58090The port of debugd. If you change it, also set DEBUG_DAEMON_PORT for debugd.