GoLand 2023.3 Help

Running

You can run applications right from GoLand if you have an GOROOT set up for your project.

Quick way

Run from the editor

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 App actions execute in the gutter near the class declaration and select Run.

    Run using the gutter icon
  • 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.

Customizable way

  1. Click App actions execute in the gutter near the class declaration and select Modify Run Configuration.

    Modify run configuration
  2. 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.

    Go run customizable 2

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

For more information about tool windows and how to manage them, see the Tool windows topic.

List of fields in run/debug configurations

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

  • Directory: build an application in the specified directory as a package, without processing any subdirectories.

    For test configurations, GoLand runs all the tests in the specified directory and all its subdirectories.

  • File: build an application from files specified in the Files field. To pass multiple file paths, use the vertical bar (|) as a delimiter. This configuration is automatically selected when you run your program from scratch files.

  • Package: build a single package with all its dependencies. Specify a full import path to the package that you want to build in the Package path field (for example, github.com/gorilla/mux). This configuration is automatically selected when you run the main function or a separate test by using the Run icon (the Run button) in the gutter.

Package path

A full import path of the package that you want to compile (for example, github.com/gorilla/mux). This field is available only when you select the Package run kind.

You can press Control+Space to see a list of available packages.

Autocompletion for the Package path field

Output directory

A directory for the executable file.

Run after build

Execute the application after the build.

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.

Add an environment variable

Go tool arguments

Arguments for the go tool (for example, -o). Also, you can use macros in this field.

Use all custom build tags

All tags that are applied during the build. Tags are listed in settings Control+Alt+S under Go | Build Tags.

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 Alt+Insert 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.

Re-run applications

  • On the toolbar of the Run tool window, click the Rerun button or press Shift+F10.

    Re-run button

Stop and pause applications

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.

Stop a program

  • In the Run tool window, click the Stop button on the toolbar. Alternatively, press Control+F2 and select the process to stop.

Pause the program output

  • Right-click in the Run tool window and select Pause Output from the context menu. Use the same toggle to resume the program.

Show running processes

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.

    A list of running 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.

Last modified: 10 January 2024