GoLand 2017.3 Help

Discover GoLand

This guide is intended to help you become more productive with GoLand, and provides an overview of the most important features, together with tips, tricks, and the hottest shortcuts.

User interface

The most interesting part of the user interface is the GoLand Editor since it lets you invoke almost any IDE feature without leaving it, which helps you organize a layout where you have more screen space because auxiliary controls like toolbars and windows are hidden.

go UI

If you want to focus on the code, try the Distraction Free Mode. It removes all toolbars, tool windows, and editor tabs. To switch to this mode, on the main menu select View | Enter Distraction Free Mode.
Alternatively, you can press Ctrl+Shift+F12 to hide all tool windows and press it again to restore the layout.

Accessing a tool window via its shortcut moves the input focus to it, so you can use all keyboard commands in its context. When you need to go back to the editor, pressEscape.

Below is a list of shortcuts that invoke the tool windows you will most often need:

Tool WindowShortcut
Project Alt+1
Version Control Alt+9
Run Alt+4
Debug Alt+5
Terminal Alt+F12
Editor Escape

The Navigation Bar is a compact alternative to the Project. To access the Navigation Bar, press Alt+Home.

go navigation tool bar

Most components in GoLand (both tool windows and pop-ups) provide speed search. This feature allows you to filter a list, or navigate to a particular item by using a search query.

go speed search

To access the project structure where you can manage content roots, resource roots, and files, select File | Settings/Preferences | Project Structure.

go project structure

GoLand lets you work with several projects simultaneously. In the Project tool window, click the External Libraries node and then the GOPATH node. Locate the project you want to add, right-click it and from the context menu select Add directory to current project.

go add dir to project

GoLand adds a project to the currently opened one.

go add dir result

Editor basics

Since in GoLand you can undo refactorings and revert changes from Local History, it makes no sense to ask you to save your changes every time.

The most useful Editor shortcuts are:

ActionDescription
Move the current line of code Ctrl+Shift+Up Ctrl+Shift+Down
Duplicate a line of code Ctrl+D
Remove a line of code Ctrl+Y
Comment or uncomment a line of code Ctrl+Slash
Comment a block of code Ctrl+Shift+Slash
Find in the currently opened file Ctrl+F
Find and replace in the current file Ctrl+R
Next occurrence F3
Previous occurrence Shift+F3
Navigate between opened tabs Alt+Right Alt+Left
Navigate back/forward Ctrl+Alt+Left Ctrl+Alt+Right
Expand or collapse a code block in the editor Ctrl+NumPad Plus Ctrl+NumPad -
Create new... Alt+Insert
Surround with Ctrl+Alt+T
Highlight usages of a symbol Ctrl+F7

To expand a selection based on grammar, pressCtrl+W. To shrink it, press Ctrl+Shift+W.

GoLand can select more than one piece of code at a time. You can select/deselect any piece of code via Alt+J, or by clicking a code selection and pressing Shift+Alt+J.

You can expand a live template by typing its abbreviation in the Editor and pressing Tab. To see the list of all available live templates and to define your own, select File | Settings/Preferences | Editor | Live Templates .

Code completion

When you access Basic Completion by pressing Ctrl+Space, you get basic suggestions for variables, types, methods, expressions, and so on.

The Smart Completion feature is aware of the expected type and data flow, and offers the options relevant to the context. To call Smart Completion, press Ctrl+Shift+Space.

If you want to see the suggested parameters for any method or function, press Ctrl+P. GoLand shows the parameter info for each overloaded method or constructor, and highlights the best match for the parameters already typed.

The Postfix Completion feature lets you transform an already typed expression to another one, based on the postfix you type after a dot.

Recent files

Most of the time you work with a finite set of files, and need to switch between them quickly. A real time-saver here is an action called Recent Files invoked by pressing Ctrl+E. By default, the focus is on the last accessed file. Note that you can also open any tool window through this action:

go recent files

Structure

When you are not switching between files, you are most probably navigating within a file. The simplest way to do it is to press Ctrl+F12. The pop-up shows you the structure of a file, and allows you to quickly navigate to any of them.

go file structure

Select in

If you need to open a file in a particular tool window (or Finder/Explorer), you can do so via the Select In action by pressingAlt+F1:

Navigate to type, symbol, file

Navigate to Type is available by pressing Ctrl+N and lets you find types and interfaces. If you call it twice, it shows you the results out of the project.

Navigate to File works similarly by pressingCtrl+Shift+N, but is used for files and folders. To navigate to a folder, end your expression with the Slash character.

Navigate to Symbol is available by pressing Ctrl+Shift+Alt+N and lets you find functions, methods, variables, and types.

Navigate to type declaration is available by pressing Ctrl+Shift+B.

Other useful navigation shortcuts include:

ActionShortcut
Search everywhere Double Shift
File structure Ctrl+F12
Navigate to declaration Ctrl+B
Navigate to type hierarchy Ctrl+H

Quick pop-ups

Quick Pop-ups are helpful for checking additional information related to the symbol at the caret. Below is a list of pop-ups you should know if you want to be more productive:

ActionShortcut
Documentation Ctrl+Q
Quick definition Ctrl+Shift+I
Show usages Ctrl+Alt+F7
Show implementation Ctrl+Alt+B

Refactoring basics

GoLand offers a set of automated code refactorings that leads to significant productivity gains when used correctly. Firstly, don't bother selecting anything before you apply a refactoring. GoLand is smart enough to figure out what statement you're going to refactor, and only asks for confirmation if several choices are possible.

ActionShortcut
Rename Shift+F6
Extract variable Ctrl+Alt+V
Extract constant Ctrl+Alt+C
Extract function Ctrl+Alt+M
Inline Ctrl+Alt+N
Copy F5
Move F6
Refactor this Ctrl+Shift+Alt+T

Finding usages

Find Usages helps you quickly find all pieces of code referencing the symbol at the caret (cursor), no matter if the symbol is a method, field, parameter, or another statement. Just press Alt+F7 and get a list of references grouped by usage type, module, and file.

If you want to set custom options for the Find Usages algorithm, press Ctrl+Shift+Alt+F7.

If what you're looking for is plain text, use Find in Path by pressing Ctrl+Shift+F.

Inspections

Inspections are built-in static code analysis tools that help you find probable bugs, detect performance issues, and improve the overall code structure.

Most inspections not only tell you where a problem is, but also provide quick fixes to deal with it right away. Press Alt+Enter to choose a quick fix.

Inspections that are too complex to be run on-the-fly are available when you perform code analysis for the entire project. You can do this in one of the following two ways: by selecting Code | Inspect Code from the main menu, or by selecting Code | Run Inspection by Name to run an inspection by its name.

Note that while inspections provide quick-fixes for code that has potential problems, intentions help you apply automatic changes to code that is correct. To get a list of intentions applicable to the code at the caret, pressAlt+Enter.

Code style and formatting

GoLand lets you format your code automatically and manually.

To enable auto-formatting, configure File Watchers located in Settings/Preferences | Tools.

To reformat Go code manually, you can use Reformat Code action or you can select Tools | Go Tools | Goimports file. You can also use the Go fmt file and Go fmt project options.

Note that the Go fmt option is also available in the Commit Changes dialog as a Before Commit action.

Useful formatting shortcuts:

ActionShortcut
Reformat code Ctrl+Alt+L
Auto-indent lines Ctrl+Alt+I
Optimize imports Ctrl+Alt+O
Go fmt fileCtrl+Shift+Alt+F
Go fmt projectCtrl+Shift+Alt+P

Version control basics

To check out a project from a Version Control System (VCS), click Checkout from Version Control on the Welcome Screen, or in the main VCS menu.

To quickly perform a VCS operation on the current file, directory, or an entire project, use the VCS operations pop-up by pressing Alt+Back Quote

go vcs operations

Once you've configured the VCS settings, you'll see the Version Control tool window. You can switch to it anytime by pressingAlt+9.

The Local Changes tab of the Version Control tool window shows your local changes: both staged and unstaged.

Useful VCS shortcuts:

ActionShortcut
Version Control tool window Alt+9
VCS operations pop-up Alt+Back Quote
Commit changes Ctrl+K
Update project Ctrl+T
Push commits Ctrl+Shift+K

Branches

To perform an operation on a branch, either select Branches from the VCS main or context menu, the VCS operations pop-up, or the widget on the right of the status bar.

Note that for multiple repositories, GoLand performs all VCS operations on all branches simultaneously, so you don't need to switch between them manually.

Shelves, stashes and patches help you when you need to store some of the local changes without committing them to the repository. You can then switch to the repository versions of the files, and then come back to your changes later.

Build, run, and test

Once you've created a Run/Debug configuration by selecting Run | Edit Configurations from the main menu, you are able to run and debug your code.

ActionShortcut
Run Shift+F10
Debug Shift+F9

You can test an application using Run with Coverage action that lets you see your source code measurements. You can also configure coverage settings located in Settings/Preferences | Build, Execution, Deployment | Coverage.

When in the debug mode, you can evaluate any expression by using the Evaluate expression tool, which is accessed by pressing Alt+F8. This tool provides code completion in the same way as in the editor, so it's easy to enter any expression.

ActionShortcut
Toggle breakpoint Ctrl+F8
Step into F7
Step over F8
Step out Shift+F8
Resume F9
Evaluate expression Alt+F8

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: 14 February 2018

See Also