GoLand 1.0 Help

Getting Started with GoLand

Setting up a workspace

It's recommended to keep all Go code in single a workspace with the following layout:

  • work
    • bin
    • pkg
    • src
      • github.com
        • user_name
          • project1
          • project2

Also make sure the environment variable GOPATH is defined and points out to the workspace location. This variable will be used by Go commands and the IDE to resolve import statements, install, build and update packages, etc.

Setting up a project from existing sources

To import an existing project, click Open in the Welcome screen and select the project directory (preferably inside the workspace, see earlier).

After the project is opened, go to Settings → Go → GOROOT and select a Go distribution. If none available, make sure to download a copy, and then select it.

After the SDK is set, please wait until the IDE has indexed the workspace. This may take awhile but will pay off later with instant coding assistance.

Changing the Go SDK (GOROOT)

The Go SDK for the current project can be always set or changed in Settings → Go → GOROOT.

go ge02

The Go SDK configuration process is the same if you use the Go AppEngine SDK.

Setting up a project from scratch

To create a blank project, click Create New Project in the Welcome screen and choose Go as your project type in the Project Wizard, then select a project SDK (or configure a new one as described above) by clicking Configure.

You’ll be prompted to choose a project name and directory (preferably inside the workspace, as described earlier ), and a Go SDK (GOROOT).

go ge04

Changing the GOPATH settings

Both global and project-level GOPATH settings can be changed in Settings → Go → GOPATH.

go ge01

If you'd like to use a GOPATH different from the one specified in the environment variable, clear the option Use GOPATH that's defined in system environment and select the one you want.

Running application

To run a Go application or tests written in Go, you'll need a Run Configuration. To define it, use the main menu Run → Edit Configurations. In the Run/Debug Configuration dialog (that shows up after you click Edit Configurations), click the Plus button and choose the type of Run Configuration that you need:

  • The Go Application type is equal to go build command.
  • The Go Single File type is equal to go run.
  • The Go Test type is equal to go test. Make sure to select the test framework your tests use: gotest, gocheck or gobench.
  • The Go App Engine type lets you deploy your application to Google AppEngine. Note, it requires your Go module to use a Go AppEngine SDK.
go ge03
go ge00

After your Run Configuration is configured, you can run it any time via the main menu Run → Run (or Debug if it's what you need).

Coverage

If you're running tests and would like to see coverage, use the Run with Coverage action. It's available from the Navigation Bar next to selected Run Configuration.

Using coding assistance

  • Basic code completion:N/A.
  • Statement completion:N/A).
  • See parameters for a method or constructor:N/A.
  • Browse documentation for a symbol at the caret:N/A.
  • Navigate to the declaration of a symbol at the caret:N/A.
  • Navigate to the declaration of any symbol: hold Ctrl (Cmd for macOS) and click the left mouse button on that symbol.
  • View current file structure:N/A. In that popup you can select a memmber and press Enter to navigate to it within the file.
  • Rename a symbol at the caret:N/A. Press twice to see the Rename dialog with more options.
  • Usually your code is being formatted automatically as you type. To re-format it manually, use Code → Go Tools → Go fmt file or Code → Go Tools → Goimports file in the main menu. Note that the Go fmt option is also available in the Commit Changes dialog as a Before Commit action.
  • See a popup with usages of a symbol at the caret:N/A. To see usages in a tool window, press N/A. For more options, pressN/A.
  • Expand a live template: type its abbreviation in the Editor and press Tab. To see the list of all available live templates and to define your own, go to Settings → Editor → Live Templates and find the Go group.
  • Debugger actions: Step Over viaN/A, Step Into viaN/A, Evaluate Expression via N/A and Toggle Breakpoint viaN/A.

We also recommend that you read the Discover IntelliJ IDEA document to better know how IntelliJ-based IDE work.

To better know how the IntelliJ platform works, we recommend that you read the Discover IntelliJ IDEA document.

To hear about new features as they come out, follow us on Twitter or read our blog.

Sending your feedback

Your feedback is welcome in the GoLand issue tracker at https://youtrack.jetbrains.com/issues/GO

Last modified: 2 November 2017