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.
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.
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:
The Navigation Bar is a compact alternative to the Project. To access the Navigation Bar, press Alt+Home.
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.
To access the project structure where you can manage content roots, resource roots, and files, select.
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.
GoLand adds a project to the currently opened one.
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:
|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|
|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 -|
|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 .
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.
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:
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.
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:
|Search everywhere||Double Shift|
|Navigate to declaration||Ctrl+B|
|Navigate to type hierarchy||Ctrl+H|
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:
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.
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 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 selectingfrom the main menu, or by selecting 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 .
To reformat Go code manually, you can use Reformat Code action or you can select . 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:
|Go fmt file||Ctrl+Shift+Alt+F|
|Go fmt project||Ctrl+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 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
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:
|Version Control tool window||Alt+9|
|VCS operations pop-up||Alt+Back Quote|
To perform an operation on a branch, either selectfrom the main or context menu, the , 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 selectingfrom the main menu, you are able to run and debug your code.
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 .
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.
Sending your feedback
Your feedback is welcome in the GoLand issue tracker at https://youtrack.jetbrains.com/issues/GO