GoLand の新機能

GoLandの新機能

GoLand 2020.2 introduces new features for Go modules, new ways to review and fix problems in your code, and a set of new code inspections. On top of that, you will find new code editing features, such as the long-awaited Add Caret Per Selected Line , experimental support for generics, the ability to share code to the Go Playground from the editor, updates for version control including WSL 2 support for Git on Windows, and more!

Prefer to learn interactively instead of reading? Complete the GoLand 2020.2の新機能 tutorial inside the IDE on the ようこそ screen.

Goモジュールの改善

Set new GOMODCACHE environment variable in the Environment Variables dialog

Starting with Go 1.15, you can change the default location of the modules cache from $GOPATH/pkg/mod to another folder using the new GOMODCACHE environment variable.

To do that, just set GOMODCACHE in 環境設定/設定 | Goモジュール | 環境 . The IDE will recognize the custom location and use it for all subsequent actions with dependencies.

Commenting module dependency in the go.mod file

The 行コメントの適用 ( Ctrl+/ on Windows/Linux and ⌘/ on macOS) action is now available for the go.mod file.

GoLand completes a closing brace in go.mod file for replace statement

GoLand now immediately adds a closing brace when you type the opening brace for replace, exclude, and require statements.

Get everything from comments

Navigation from comment to source code

The IDE displays references from comments to related package-level declarations and lets you navigate to them via the 宣言または使用箇所に移動する action ( ⌘B on macOS and Ctrl+B/ on Windows/Linux).

コード・インスペクション

Navigation through warning and errors in the file via the Inspections Widget

The new Inspections Widget shows the number of warnings, errors, and typos in the current file in the upper right-hand corner of the code editor. You can go through them using the arrow icons or the 次のエラー action ( F2 ).

The widget lets you configure the highlighting level (select from none, errors only, or all problems), change the severity level of inspections, and toggle it to the Compact View so it won’t distract you.

Moving to error from the Problems View and fixing it via Alt+Enter

The 問題 tool window displays a list of warnings and errors in the current file, gives you a description of those problems, and lets you fix them immediately using Alt+Enter .

To open the 問題 tool window, click on the Inspections Widget or go to 表示 | ツール・ウィンドウ | 問題 . Right-click on a problem to move directly to the line of code where the error occurred.

GoLand warns about a possible problem in conversion and suggest to fixing it via Alt+Enter

A new code inspection handles possible problems with string(int) conversions which return the UTF-8 representation of the Unicode code point x instead of the expected decimal string representation of x .

GoLandは、そのような潜在的なミスについて通知し、専用のクイックフィックスを提供します。

GoLand warns about an incorrect test name and suggests fixing it via Alt+Enter

GoLand will notify you about common erroneous usages of tests and examples, so you don’t need to call go vet explicitly for that anymore. The IDE also provides quick-fixes in simple cases; for example, it suggests renaming Testme to TestMe .

The Malformed struct tag code inspection alerts the user to a possible problem

The 不正な構造タグ code inspection will check that struct tags conform to Go conventions and notify you about potential problems.

GoLand alerts the user about an impossible interface assertion

The Impossible interface type assertion code inspection checks for type assertions v.(T) and corresponding type-switch cases in which the static type V of v is an interface that cannot possibly implement the target interface T .

This occurs when V and T contain methods with the same name but different signatures.

コード編集

Show Context Actions shows possible options to apply

To preview the result of an intention action or quick-fix before you apply it to your code, invoke the コンテキスト・アクションの表示 with the Alt+Enter shortcut, select the required intention action or quick-fix, and press ⌥+Space on macOS or Ctrl+Shift+I on Windows and Linux.

The Add Caret Per Selected Line action creates carets at the end of each selected line

The new Add Caret Per Selected Line action creates carets at the end of each selected line and deselects the lines. Invoke it using the shortcut Alt+Shift+G on Windows/Linux or ⌥⇧G on macOS.

The Put arguments on one line intention action splits an expression into separate lines

Configure wrapping for call arguments, function parameters, and composite literal elements in 環境設定/設定 | エディター | コード・スタイル | Go | 折り返しおよび括弧 .

Alternatively, you can use the 引数を別々の行に配置する and 引数を 1 行に保持する intention actions using Alt+Enter to split and join elements manually.

Take control of variadic arguments

Inline Variable refactoring unpacks a slice into variadic arguments

変数を導入するリファクタリング(WindowsおよびLinuxのCtrl+Alt+V、またはmacOSの ⌘⌥ V )は、いくつかの可変引数を新しいスライス変数にパックできます。一方、変数のインライン化(macOSの⌥⌘N およびLinuxおよびWindowsの Ctrl+Alt+N )は、逆にスライスを可変引数にアンパックします。

The Unpack slice quick-fix in action

In addition, you can now handle issues with unpacked variadic arguments via the Unpack slice quick-fix.

プロジェクトをテンプレートとして保存する

Save Project as Template tool window

You can now reuse projects or files by saving them as custom project templates: select ツール | テンプレートとしてプロジェクトを保存 . The IDE will recreate the project tree with files, folders, and build configurations.

Go Playground

Share in Playground action in the dropdown menu

これで、エディター内をダブルクリックして、Go Playground(英語)でコードを共有および実行できます。ドロップダウンメニューでGo ツール | Share in Playgroundまたはツール | Go ツール | Share in Playgroundを選択するか、macOSでは ⌥⇧⌘S、Windows / Linuxでは Ctrl+Alt+Shift+S を押します。

This also works for go2 files to play with generics, in which case GoLand will take you to the new https://go2goplay.golang.org/(英語)

Generics a.k.a. type parameters

go2 files are opened in the editor with syntax highlighting and basic reference resolution

The Go Team recently announced a draft design for generics. Please visit the Golang documentation for full details of the concept(英語).

GoLand 2020.2 provides experimental support for generics that you can play with by turning on the Enable experimental support for generics a.k.a. type parameters setting in 設定/環境設定 | Go .

This initial support provides syntax highlighting and basic reference resolution, and works in go2 files only.

もっと詳しく

Sync dependency via Alt+Enter

With vendoring mode enabled, you build your application with only the dependency packages that are stored in the vendor folder in your project.

Now if a project has a vendor folder and you’ve checked the Enable vendoring mode automatically setting in 設定/環境設定 | Go | Goモジュール , resolve will only use the vendor/ folder and will not consult the modules cache.

GoLand shows go list progress in the progress bar

GoLand runs go list commands sequentially and provides a progress bar with information about the actual numbers of go list commands in the queue.

バージョン管理

WSL2 support for Git on Windows

WSL 2 support for Git on Windows

GoLand 2020.2 will allow you to use Git from WSL 2, which is natively available in the May update of Windows 10, version 2004(英語) . If Git is not installed in Windows, GoLand will automatically look for Git in WSL and use it from there. It will also automatically switch to Git from WSL for projects opened from WSL (via \wsl$ path ).

Improved Git action dialogs

Improved Git action dialogs

We’ve redesigned the Git dialogs for actions such as マージ , プル , and リベース to make them more consistent and informative. We’ve also made it easier to understand which Git command will be executed, and added the –rebase option to the プル dialog and the –no-verify option to the マージ dialog.

Start a review with a comment action

GitHubプルリクエストの完全サポート

GitHubプルリクエスト is fully equipped! Browse, assign, manage, and even merge pull requests, view the timeline and inline comments, submit comments and reviews, and accept changes without leaving GoLand.

Improved presentation of Compare branches results

Improved presentation of Compare branches results

Now when you are comparing 2 branches in GoLand, you’ll be able to see the commits of the compared branches in one view. The IDE will now open the logs of both branches being compared in the editor instead of in the VCS tool window, where there is not enough space to display all the information.

データベースの更新

Separate editor for cell values

セル値の個別のエディター

セルに大きな値がある場合は、別のパネルで表示または編集できます。右側のツールバーを使用してソフトラップモードを切り替えることもできます。コードエディターのすべての機能をデータに使用してください!

DML preview in the data editor

データエディターでのDMLプレビュー

Starting with this version, you can review the query that represents your changes in the data editor. There is now a DML button that is active if there are pending changes.

そして、DMLプレビューのダイアログが表示されます。GoLandはJDBCドライバーを使用してテーブルを更新するため、このクエリはデータを変更するために実行される正確なSQLではありませんが、ほとんどの場合は同じです。

A new UI for boolean values

ブール値の新しいUI

ブール値を表示および編集するためのよりユーザーフレンドリーな方法があります。True値は、他のすべての値と区別するために、箇条書きでマークされています。

Coding assistance for Google BigQuery dialect

Google BigQueryダイアレクト

We’ve added a new SQL dialect: Google BigQuery . Full support for BigQuery is not here yet, but all things must begin somewhere. GoLand can correctly highlight and provide coding assistance for your queries if you use Google BigQuery .

JavaScriptとTypeScript

New smart intentions

New smart intentions ( Alt+Enter ) will help you perform some actions faster. For example, you can now quickly convert a for loop with a numeric index into a forEach array method. Looking through documentation comments in JavaScript and TypeScript files has also become easier as you can now render them right in the editor, minimizing all distractions.