GoLand 2022.3 Help

Running applications in Go Playground

You can run your Go code in GoLand by using the Go playground server to process it. When you use the Open in | Playground action, GoLand creates a scratch file with your code and displays a toolbar that contains the same options that you see in the Go playground.

You can format and share your code, change the Go version, run your code by using the Go playground server, or run it locally.

GoLand displays a toolbar with the Go Playground controls for Go scratch files.

the Go playground inside GoLand

Running your code in the Go Playground

  1. Select code that you want to run in the Go Playground.

  2. Right-click the selection and navigate to Open In | Playground.

  3. Click the Run icon (the Run icon) on the toolbar.

    Note: if you run your code from the context menu or from the gutter, GoLand runs your code locally. Also, you can run your code locally by selecting the Run locally.

Load code from file or URL

  1. From the main menu, select File | New | Scratch File or press Ctrl+Alt+Shift+Insert.

  2. From the New Scratch File window, select Go.

  3. On the toolbar, click the Load icon (the Load icon).

  4. In the dialog, select the source of your code: File or URL.

  5. Click OK.

Format code with the Go Playground formatter

  1. Open your code in a scratch file. For more information about scratch files, see Scratch files.

    To create a new file, select File | New | Scratch File from the main menu or press Ctrl+Alt+Shift+Insert.

  2. On the toolbar, click the Format icon (the Format icon).

    Format code with the Go Playground formatter

Share code in the Go Playground from scratch files

  1. Open your code in a scratch file. For more information about scratch files, see Scratch files.

    To create a new file, select File | New | Scratch File from the main menu or press Ctrl+Alt+Shift+Insert.

  2. On the toolbar, click the Format icon (the Format icon).

    Share code in the Go Playground from scratch files

Selecting Go version

  1. Open your code in a scratch file. For more information about scratch files, see Scratch files.

    To create a new file, select File | New | Scratch File from the main menu or press Ctrl+Alt+Shift+Insert.

  2. From the Go version drop-down, select the version that you want.

Selecting context of a module

  1. Open your code in a scratch file. For more information about scratch files, see Scratch files.

    To create a new file, select File | New | Scratch File from the main menu or press Ctrl+Alt+Shift+Insert.

  2. From the Go version drop-down, select the version that you want.

Last modified: 12 December 2022