Start the debugger session
Starting a debugger session is very similar to running the program in normal mode. The debugger is attached behind the scenes, so you don't have to configure anything specific to start a debugger session. If you are able to run your program from GoLand, you will also be able to debug it using the same configuration.
note
While GoLand provides a way to debug simple applications without any extra setup, some tasks require working with run/debug configurations, just like with regular running of the program.
Each time you debug a program, the debugger session is based on a run/debug configuration. It allows you to configure parameters and actions for launching the application. For example, you can specify to build the application every time you start a debugger session or use the previously compiled code.
To run the program from an entry point, such as the main() method or a test, click Run
icon in the gutter near it and select Debug.
This will create a temporary run/debug configuration for you. After that, you can customize and save this temporary configuration if needed. This is the quickest way to debug your program without configuring the startup parameters.
If you already have a run/debug configuration, select it in the run widget, then click Debug or press ShiftF9.
To launch a debug session for an existing run/debug configuration from the editor, press AltShiftF9 and select it from the menu.
When the debugger session is running, you can pause/resume it using the buttons on the toolbar of the Debug tool window:
To pause a debugger session, click
.
To resume a debugger session, click
F9.
note
Pausing the program is not an alternative to using breakpoints as this method doesn't let you use the full range of debugger functionality. For example, you cannot evaluate expressions after pausing the program.
Click
in the Debug tool window.
Alternatively, press CtrlF2 and select the process to terminate (if there are two or more of them).
To run or debug multiple tasks simultaneously, open the run widget menu in the toolbar and select the corresponding run/debug configurations while holding down the Ctrl key.
For launching multiple tasks using a single run/debug configuration, refer to Run/debug multiple targets.
The Services tool window shows multiple go build
run/debug configurations launched by a user. To hide specific configurations, such as a CLI tool, clear the checkbox for the Go Build tree item.
![display of multiple run configurations display of multiple run configurations](https://resources.jetbrains.com/help/img/idea/2024.3/go_display_of_multiple_run_configurations.png)
Set breakpoints in the source code.
If necessary, create or modify the corresponding Run/Debug configuration.
The debug session starts with the selected run/debug configuration. Note that several debug processes can be launched simultaneously.
tip
Alternatively, press AltShiftF9, select the configuration from the list, and press Enter.
Thanks for your feedback!