New Features in GoLand 2020.3
A selection of useful features from GoLand 2020.3
GoLand 2020.3 was released on December 3rd, 2020! It allows you to explore goroutine dumps, run and navigate individual tests in table tests, improved support for the time package, collaborative development and pair programming, Code With Me, among other new features and enhancements!
Check out DataGrip 2020.3 What's New and WebStorm 2020.3 What's New to read all about the new features related to database and modern web development included in GoLand.
Retract Directive
Retract specific versions of your modules.
From the Go documentation for the retract directive:
A retract directive indicates that a version or range of versions of the module defined by go.mod should not be depended upon. A retract directive is useful when a version was published prematurely or a severe problem was discovered after the version was published.
This feature does not require anything special to be used. The IDE recognizes it automatically.
Dump Goroutines from a Running Application
Inspect the goroutines and memory of your application as it runs.
Regardless if it's for fun, or investigating a bug, having a quick look at what the application is doing and its memory is always useful.
Either attach to the project using the debugger, or launch a debugging session. While the application is running, press the 📷 button on the left side of the Debugger tool window.
Stop a Remote Process After Debugging It
Clean-up processes after interacting with them in remote debugging scenarios.
Create a new Go Remote run configuration type via _Run | Edit Configurations... | + Go Remote. In the run configuration settings, in the On disconnect section, choose either Stop remote Delve process, Leave it running, or Ask to determine how the configuration behaves when you stop the debugger.
Inline Watches in Debugger
Keep your eyes on the code at all times.
During debugging, you can keep your eyes on the code at all times, without having to check the Debugger tool window for the values of variables that you are interested in.
The best part? When you move away to a different scope, if the variable is not contained by it, it won't be shown in the Debugger tool window either.
During a debugging session, right click on any variable you'd like to watch and select Add inline watch from the context menu.
Run a Single Test
Focus your testing on new test cases or tests that fail.
When you have a testing table of more than a handful of cases, it can be hard to focus on a specific test case.
If the IDE can determine the name of the test, then you can use either the green arrow next to the test name or using Run context configuration via ⌃⇧R (macOS) / Ctrl+Shift+F10 (Windows/Linux).
Note: This feature relies on the IDE to interpret the test name. This means that there are some restrictions on how to name your tests for the IDE to correctly determine them and provide this functionality:
- The test data variable must be a slice, an array, or a map. It must be defined in the same function as the call and must not be touched after initialization (except for range clauses in a for loop).
- The individual test data entry must be a struct literal. Loop variables used in a subtest name expression must not be touched before the call.
- A subtest name expression can be a string field in the test data, a concatenation of test data string fields, and an
fmt.Sprintf()
call with%s
and%d
verbs.
Navigate to Subtests
Jump to the specific test case from the results window.
If you need to review the parameters for a certain test case, then you can use the Jump to source, ⌘↓ (macOS) / F4 (Windows/Linux) feature to do so. You can also double-click on the subtest name in the UI, and it will perform the same action.
Completion for Testify Test Names
Let your IDE add constructor arguments to your instance.
Type Run and the IDE will suggest suite. Run as a completion option. When you select that, the IDE will automatically complete the line to suite.Run(t, |). You can then start typing the testify suite name at the caret position, |
Run Individual Testify Test Suites
Run only the testify test suites or subtests that matter to you.
Use either the green arrow next to the test name or using Run context configuration via ⌃⇧R (macOS) / Ctrl+Shift+F10 (Windows/Linux).
Rerun Testify Subtests
Rerun just the subtest you need from a testify suite.
Use either the green arrow next to the test name or using Run context configuration via ⌘⇧F10 (macOS) / Ctrl+Shift+F10 (Windows/Linux).
Alternatively, you can select the subtest from the runner window and choose to rerun the subtest you want.
Assert Completion in Testify
Write testify asserts faster thanks to the IDE smartness.
Type the assert function call and let the IDE automatically fill the testing.T parameter in the assert function call.
Detect Incorrect Usages
Formatting functions from packages such as pkg/errors, logrus or zap.
You don't need to do anything particular to use this feature. When using any output formatting function which is similar to fmt.Printf/fmt.Println from a package such as pkg/errors, logrus, or zap. A small list of these functions are: errors.Errorf(), or logrus.WithError().Infof().
Check context.CancelFunc Usage
Ensure that the cancel function is always called.
In code that uses a context.WithCancel call, check for any warning messages. If one shows up, you can use the Show Context Action menu, ⌥⏎ (macOS) / Alt+Enter (Windows/Linux), and use either the Navigate to 'cancel' function or Navigate to the end of the problematic execution path options from it. By using these feature, you can then gain the insight into what the IDE sees as a problematic execution path, and place the correct call to the cancel function.
Better Time Format in Completion
Use the commonly known date/time formatting strings while writing time formatting in Go.
It's no secret that Go uses different references for formatting date/time. When coming from other programming languages, you may try to use YYYY instead of Go's 2006 string to format the year. This is where GoLand can help you by suggesting the common date/time formats, such as YYYY or DD and converting them to Go's formatting directives.
Start typing any common date/time formatting strings, such as YYYY or DD and the IDE will convert them automatically. You can also use other identifiers, such as year or day, to activate this feature. This works for both time.Time.Format
and time.Parse
functions.
Detect Variable Shadowing While Writing Go Code
Easily spot where you shadow variables that you did not intend to
While writing code, observe if the variable color changes. If it does, then invoke the Context Actions menu via ⌘⌥⏎ (macOS) / Ctrl+Alt+Enter (Windows/Linux) and select Navigate to shadowed declaration to identify the originally shadowed identifier.
Live Template to Create Test Function
Write tests faster thanks to the builtin func Test live template.
Place the cursor at the file level in a _test.go file and start typing func. Select the Test option from the suggested list and then complete this by writing the test name you desire.
Pro tip: You can invoke the Completion feature, ⌃␣ (macOS) / Ctrl+Space (Windows/Linux), to create test for methods too, not just functions.
Live Template to Write Benchmark Functions
Write benchmarks quicker thanks to the builtin bench live template.
Place the cursor at the file level in a _test.go file and start typing func. Select the Benchmark option from the suggested list and then complete this by writing the test name you desire.
Pro tip: You can invoke the Completion feature, ⌃␣ (macOS) / Ctrl+Space (Windows/Linux), to create benchmarks for methods too, not just functions.
Live Template to Create a for Loop
Benchmark loops are repetitive, so let the IDE handle this for you.
In a Benchmark function, start typing for and select the for loop Live Template from the list that matches the common benchmark loop for i := 0; i < b.N; i++ {}.
Drag & Drop Editor Tabs
Change how the editor tabs are grouped or split using drag and drop.
Move the editor tabs to form what layout you need, whenever you need them to.
Drag and drop the editor tabs to different locations across the IDE window. Possible drop locations will be highlighted to assist you in personalizing your IDE.
Open File in Split Editor
View two files side-by-side by directly opening the second one in a split-editor mode
Select the file in the Project View tool window or in the Navigation Bar and use ⇧⏎ (macOS) / Shift+Enter (Windows/Linux) to open the file in a split editor view.
Preview File Contents
Have a look at what's in the file without opening it.
On the Project View tool window, locate the gear icon, then click on it and select Enable Preview Tab option. After that, click on a file in the Project View, and it will allow you to preview its contents without creating a new tab that you then need to close.
You can also locate the Enable Preview Tab option using ⇧⇧ (macOS) / Shift+Shift (Windows/Linux), and turn it on.
Sync the IDE Theme with the OS Theme
Have your IDE theme synchronize with your OS one throughout the day.
Turn on the Sync with OS setting under Settings/Preferences | Appearance & Behavior | Appearance. A gear icon will show up next to this option, giving you control over which theme to apply, when. The IDE will automatically apply your preferred themes, following the OS preferences.
Perform Simple Math in Search Everywhere
Quickly perform simple math operations from the comfort of your IDE.
Invoke ⇧⇧ (macOS) / Shift+Shift (Windows/Linux), and start typing the math operations you want to perform.
Tailwind CSS Support
Enjoy working with Tailwind CSS from the comfort of your IDE.
Open any CSS file and start typing either @tailwind
directives or CSS statements such as @apply font-bold bg-blue-400;
Note: You must install the Tailwind CSS support plugin from the IDE Marketplace via Settings/Preferences | Plugins | Marketplace for this functionality to work.
Support for Vue.js 3
Upgrade to using the latest Vue.js version knowing your IDE will be there to help you.
Open any JS file and start using any Vue.js 3 related code. The IDE will provide you assistance with code completion, refactoring, find usages, and more.
Note: You must install the Vue.js support plugin from the IDE Marketplace via Settings/Preferences | Plugins | Marketplace for this functionality to work.
Query MongoDB databases using SQL statements
Run MongoDB queries in SQL format within your IDE.
Connect to a MongoDB database from the IDE, then open a Console to it and write a SQL query instead of using the MongoDB format.
To run it, press ⌃⏎ (macOS) / Ctrl+Enter (Windows/Linux) to run the query and retrieve the results.
Write SQL queries using popular database packages
Work with SQL queries and get completion and other features automatically.
SQL queries are recognized automatically when these strings are used in popular SQL packages such as database/sql, github.com/jmoiron/sqlx, and github.com/gobuffalo/pop.
The IDE automatically recognizes which databases are configured, their type, e.g. Postgres, MongoDB, etc., and provides all features available to query, refactor, or reference the database.
Use the string literal which contains the SQL query in any of the functions accepting queries from one of the supported packages, and they'll be recognized automatically.
Full Support of Mermaid Syntax
Seamlessly integrate, create, and visualize Mermaid diagrams.
The Mermaid plugin provides comprehensive Mermaid syntax support, including syntax highlighting, code completion, and navigation tools. It is compatible with .mmd
and .mermaid
file types, and it also allows you to embed and render Mermaid diagrams within Markdown files.
You can choose between the following installation options:
- In the IDE, go to
Settings
|Plugins
, search for the Mermaid plugin, and clickInstall
. - In the IDE, click
Install plugin
in the notification panel when editing.mmd
or.mermaid
files. - In the IDE, click the
Install Mermaid plugin
icon that appears in the gutter in Markdown files. - Download the plugin directly from the JetBrains Marketplace and install it by using the following procedure.
Download the Log from a Kubernetes Pod
Comb the pod log for the details needed from the comfort of your computer.
Expand the Kubernetes cluster in which the pod resides, then the Workloads | Pods section, select the pod that you need the log for, then right-click on the pod name and select Download Log.
Note: You must have the Kubernetes plugin provided by JetBrains installed for this action to work.
Open Console in Kubernetes
Attach to the console of a process running inside a container of the selected pod.
Select the pod you want from the Kubernetes view in the Services tool window, then click on Open Console. A new tab will open and a console will be attached to the running process inside the pod.
Note: You must have the Kubernetes plugin provided by JetBrains installed for this action to work.
Open Shell in Kubernetes
Run an interactive shell for the container in the selected pod.
Select the pod you want from the Kubernetes view in the Services tool window, then click on the Run Shell button. A new tab will open and a terminal will be attached to the running pod.
By default, the IDE runs /bin/bash as a shell. To run a different one, click Show Settings or open Settings/Preferences | Build, Execution, Deployment | Kubernetes and specify the shell that your pods use.
Note: You must have the Kubernetes plugin provided by JetBrains installed for this action to work.