JetBrains Fleet 1.44 Help

Go run configurations

This topic summarizes the run configurations available for Go. Each table provides keys that are available within a run configuration and their descriptions.

Examples of run configurations

The following code snippet shows examples of different run configurations. See the descriptions of the fields in go and go-test sections.

{ "configurations": [ { "type": "go", "workingDir": "/Users/jetbrains/sdk/go1.21.3/src/", "environment": { "TEMP_DIR": "/Users/jetbrains/sdk/go1.21.3/myTemp/", "GENERATE_RANDOM_PASSWORD": "true" }, "allowParallelRun": true, "dependsOn": ["runOnlyMultiplyTests"], "name": "myApp", "goExecPath": "/Users/jetbrains/sdk/go1.21.3/bin/go", "buildParams": [ "$PROJECT_DIR$/main.go" ] }, { "name": "runOnlyMultiplyTests", "type": "go-test", "workingDir": "$PROJECT_DIR$", "testRunPattern": "TestMultiply", "goExecPath": "/Users/jetbrains/sdk/go1.21.3/bin/go", "buildParams": [ "exampleWithTests" ] }, ] }

Operations with run configurations

You have the option to copy automatically generated run configurations to the clipboard and subsequently make modifications to them within the run.json file. These run configurations are automatically generated when you execute your code by using the run icon in the gutter.

Copying run configurations to the clipboard

  1. Click the Run button that is located at the upper-right corner of the code editor. Alternatively, press ⌘ R.

  2. In the list of run configurations, click the ellipsis icon and select Copy configuration.

    Once you have copied the run configuration, you can paste it into the run.json file and proceed to make any necessary parameter modifications.

    Copy run configuration to the clipboard

You can edit existing run configurations in run.json. The run.json file is located in the .fleet directory.

Editing existing run configurations

  1. Click the Run button that is located at the upper-right corner of the code editor. Alternatively, press ⌘ R.

  2. Click Edit Configurations to open run.json.

    To edit a specific run configuration, click the ellipsis icon and select Edit configuration.

    Once you have copied the run configuration, you can paste it into the run.json file and proceed to make any necessary parameter modifications.

    Copy run configuration to the clipboard

If you are going to pass parameters to your program, add VM options (for example, to allow remote debugging), or otherwise customize the startup of your program, use a run/debug configuration.

Creating run configurations

  1. Click the Run icon (⌘ R) and select Create Run Configurations in run.json.

  2. In the run.json file that opens, define running or debugging parameters. If the file is empty, press ⌥ ⏎ or click the file template link.

    Alternatively, paste and edit the following code:

    { "configurations": [ { "type": "go", "name": "myApp", "goExecPath": "/usr/local/go/bin/go", "buildParams": [ "$PROJECT_DIR$/main.go" ] } ] }

    Modify the configuration properties according to your environment.

  3. Press ⌘ R or select Run | Run & Debug from the main menu. Select the configuration that you are going to run or debug.

go

Run configuration for launching Go applications

buildParams

(required)

Build flags and a file, a directory, or a list of packages to build

goExecPath

(required)

Path to go executable

environment

Custom environment variables for the process in the form of a JSON object. To define an environment variable, add a property, where the key is the variable name and the value is the value of the variable, for example:

"environment": { "TEMP_DIR": "/home/user/temp", "GENERATE_RANDOM_PASSWORD": "true" }

dependsOn

Names of other configurations which will be executed before this configuration, for example: "dependsOn": ["first", "second"]. For more information, refer to Chained run configurations.

workingDir

Working directory for this run configuration.

allowParallelRun

When set to true, more than one instance of this configuration can run in parallel.

runParams

Application command line parameters

Default value: []

go-test

Run configuration for launching Go tests

buildParams

(required)

Build flags and a test file, a directory, or a list of packages to build

goExecPath

(required)

Path to go executable

environment

Custom environment variables for the process in the form of a JSON object. To define an environment variable, add a property, where the key is the variable name and the value is the value of the variable, for example:

"environment": { "TEMP_DIR": "/home/user/temp", "GENERATE_RANDOM_PASSWORD": "true" }

dependsOn

Names of other configurations which will be executed before this configuration, for example: "dependsOn": ["first", "second"]. For more information, refer to Chained run configurations.

workingDir

Working directory for this run configuration.

allowParallelRun

When set to true, more than one instance of this configuration can run in parallel.

testRunParams

Parameters to pass to tests

Default value: ""

testRunPattern

Pattern specifying which tests to run (the -run flag of the go test command)

Default value: ""

Last modified: 26 May 2024