Top 25 Editing Features of GoLand IDE – Part 1

Today’s post is the first one in a mini-series of posts looking at the top 25 editing features in GoLand. The best part about these features? They require zero configuration and are all built into the IDE by default, without the need to search for or install any plugins.

In case you missed our previous post about Code Completion tips, we recommend giving it a look to discover even more useful tips.

Without wasting any more time, let’s jump into the topics:

And here are the tips from the other articles in the series:

Code generation

Let’s start by generating code using the IDE.

Implement an interface

Implementing an interface is a common task that Go programmers need to do. GoLand offers the option to quickly implement an interface using the Implement methods action, Ctrl+I on Windows/Linux and ^+I on macOS, and then select either to generate a new type or use an existing type from the current file.

25 top editing features - 1 - implement interface

Structure Tags

Adding tags to a structure can be done by starting to type either json or xml  after the field type.

25 top editing features - 2 - structure tags

Custom Structure Tags

You can add your own structure field tag by going to Settings/Preferences | Editor | Live Templates and then selecting Go Struct Tags. Then you can either customize an existing template, duplicate it, or create a new one. To learn more about what the placeholders are, visit our help page on this topic.

25 top editing features - 3 - custom struct tags

Generate a test

GoLand offers the option to quickly generate a test. Invoke with Ctrl+Shift+T on Windows/Linux, Cmd+Shift+T on macOS, and select generate test from the popup. You can choose to test a function/method, the whole file, or the whole package.

25 top editing features - 4 - generate test

Text selection

Moving on, let’s manipulate the source code.

Expanding/shrinking selection

With Extend selection Ctrl+W on Windows/Linux and⌥↑ on macOS, you can quickly select parts of your code using semantic knowledge about it.

Extend selection is complemented by the Shrink Selection, Ctrl+Shift+W on Windows and Linux, and ⌥↓ on macOS, which lets you shrink the selection made using the same semantic knowledge of the source code.

25 top editing features - 5 - expand and shrink selection

Multiple selections

Multiple selections is a very powerful feature in the editor that lets you quickly select and edit multiple pieces of code at once.

Select something as you normally would, or press Alt+J on Windows and Linux, ^+G on macOS, to select the symbol at the caret.

GoLand will search through the current file until it finds a matching piece of text, which it then adds to the selection. You can press Alt+J on Windows/Linux, ^+G on macOS, again to go forward further, or Shift+Alt+J, Shift+^+G on macOS, to go back. When the search reaches the end of the file, it will start over again from the beginning.

25 top editing features - 6 - multiple selections

Select all occurrences in a file

Do you want to select all the occurrences of a piece of code? Then simply press Ctrl+Alt+Shift+J on Windows/Linux, and Cmd+^+G on macOS.

After the selection is complete, you can start editing all the fragments as if they were all the same one.

25 top editing features - 7 - select all occurences in a file

Just to remind you, if you plan to use this feature to rename something, then you should have a look at our Rename refactoring, which is designed to work safely across multiple packages, not just at the file level, with full preview and undo support.

 

That’s it for today’s post. While we present just 7 features from our list, we think that these will come in handy to any developer, new or experienced, and will increase your productivity.

Do we miss anything from the list? Or is there something else that you’d like to know about? Then drop us a message on our issue tracker, the comments section below, or on Twitter.

About Florin Pățan

Developer Advocate at JetBrains
This entry was posted in Features, Tutorial and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *