Running
You can run applications right from GoLand if you have an GOROOT set up for your project.
If you are not going to pass any parameters to your program, and your program does not require any specific actions to be performed before start, you can run it right from the editor.
Click
in the gutter near the
main
function and select Run.To run a script, open it in the editor or select it in the Project tool window, and then select Run <script file name> from the context menu.
Click
in the gutter near the class declaration and select Modify Run Configuration.
Modify the run/debug configuration as needed. For example, if you need to run your program with arguments, add the arguments to the Program arguments field.
tip
To quickly access the fields only using a keyboard, hold Alt and use the shortcut according to the hints that appear.
When the application starts, you can view its output and interact with it in the Run tool window. Every run/debug configuration creates a separate tab when you run it.
![Tabs in the Run tool window Tabs in the Run tool window](https://resources.jetbrains.com/help/img/idea/2024.3/go_run_tab.png)
tip
Use the Ctrl0F shortcut to search for text occurrences in the console output.
For more information about tool windows and how to manage them, see the Tool windows topic.
The fields that appear in the right-hand pane display the default settings for the selected configuration type.
Name | Description |
---|---|
Run kind | A building scope for your application. File and Package scopes work similarly in tests and compilation/running configurations (in terms of the scope they cover).
|
Package path | A full import path of the package that you want to compile (for example, You can press CtrlSpace to see a list of available packages. ![]() |
Output directory | A directory for the executable file. |
Run after build | Execute the application after the build. |
Emulate terminal in output console | Executes the application and displays the output in the Run tool window as it would appear in the terminal. ![]() |
Working directory | Directory that is used for the built application. If you have any code that creates relative files or directories, they will be relative to this directory. |
Environment | Environment variables for your application. To edit environment variables, click the Browse button at the end of the field. In the Environment Variables dialog, click the Add button and add the environment variables that you need. ![]() |
Go tool arguments | Arguments for the go tool (for example, |
Use all custom build tags | All tags that are applied during the build. Tags are listed in settings CtrlAlt0S under Go | Build Tags. For more information, refer to Build constraints and vendoring. |
Program arguments | Arguments for the built application. Also, you can use macros in this field. |
Run with sudo | Grant sudo privileges for the application. |
Module | Name of the current module. |
Before launch | Add tasks that you want to launch before the launch of the selected run/debug configuration. To add a task click the Add button AltInsert and select the tool that you want to add. |
Store as project file | Enable this option to save your configuration as a project file and share it with team members through VCS. |
On the toolbar of the Run tool window, click
or press ShiftF10.
tip
If you re-run an application, the output of the previous run is lost. To preserve the output of an application, click the Pin Tab button on the toolbar of the Run tool window. When a tab is pinned, new sessions are opened in another tab.
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)
When you stop a program, its process is interrupted and exits immediately. When you pause a program, it continues running in the background, but its output is suspended.
In the Run tool window, click
on the toolbar. Alternatively, press CtrlF2 and select the process to stop.
Right-click in the Run tool window and select Pause Output from the context menu. Use the same toggle to resume the program.
note
Only the output is suspended. Pausing the output does not affect the execution of the program.
You can view the list of all active run or debug sessions and navigate between them.
Go to Run | Show Running List. In the top-right corner of the editor, GoLand shows a list with all active applications.
When you run, debug, or test your code, GoLand creates a temporary run/debug configuration. This configuration includes all the details of how you want to perform the operation. Usually, a temporary configuration is enough to run or debug your code. You can use the temporary configuration to run your application one time, or save it for future use.
Depending on your purposes, you can edit existing or create new configurations. For more information about editing you configurations, refer to Run/debug configurations.
You can review the output from your running applications in the Run tool window. The output from each application is displayed in its own tab, named after the corresponding run/debug configuration.
If you re-run an application, the new output overwrites the contents of the tab. To preserve the output of an application, even if you re-run it, pin the output tab: right-click the tab and select Pin Tab.
Thanks for your feedback!