LoginSignup
0
0

More than 3 years have passed since last update.

The Hitchhiker's Guide to GoLand 2019.3

Posted at

はじめに

「The Hitchhiker's Guide to GoLand」の 2019.3 版新機能チュートリアルです。
( 2019.2 版はこちら)


環境

  • macOS Catalina 10.15.2
  • GoLand 2019.3.1
  • go version go1.13.3 darwin/amd64

TL;DR

  1. ショートカットを通して GoLand 2019.3 新機能を知るチュートリアル
  2. チュートリアルメニュー
  3. 個人的に有益だったチュートリアルの紹介

The Hitchhiker's Guide to GoLand 2019.3 お品書き

チュートリアルは全部で 6 項目あります。

  1. Delete unused parameters
  2. Delete parameter names
  3. Short and long type specification for parameters
  4. Better names for error variables
  5. Better variable names for the forr live template
  6. Create a function from the function type

個人的に有益だったチュートリアル

  1. 「4. Better names for error variables」はダルい for 構文のテンプレートなので使う局面は割とありそう

1. Delete unused parameters

未使用パラメータを削除する機能。
こういったリファクタ機能が文字列置換と違って便利なのは、関連箇所を文脈的に一括修正できるところですね。
また、このあたりまでくると気付いてきますが、たいていの機能は option + return からのコンテキストメニューで出てきます。
ss-the-hitchhikers-to-guide-2019.3-delete-unused-parameter.gif


2. Delete parameter names

チュートリアル説明としては「未使用パラメータを強調表示する」とあります。
前段 1 の赤文字 string 型指定部分ですね。
関数書き始めた段階で赤くしてくるので「分かっとるわ!ちょっと黙ってろ!」になることが多いです。
チュートリアルで行う内容は前段 1 と同じなので割愛します。


3. Short and long type specification for parameters

同じ型指定が連続している場合に省略・冗長をトグルする機能です。
(良し悪しは別として)同じ型の引数が 5 個くらい連続したらまとめてもいいかなと思いますが、チュートリアルのように 2 個程度であれば冗長でもきちんと指定しておきたい派です。
これも option + return のコンテキストメニューから操作します。
ss-the-hitchhikers-to-guide-2019.3-Short and-long-type-specification-for-parameters.gif


4. Better names for error variables

Goland はエラー変数のより良い名前を提案するようになりました!
とあるのですが、なんでそれが e なんでしょうね。。err じゃないんかい。
Better names for error variables.gif


5. Better variable names for the forr live template

for 文のテンプレート機能。
スライス型変数に続けて入力で、
.for でオフセットのみ受ける for 文。
.forr で key:value 形式の for 文になります。
for 文書くのが若干ダルい局面はあるので、効率化を図れるかも知れません。
なお、テンプレートは command + , で設定を開き、Live Template で編集が可能です。
Better variable names for the forr live template.gif


6. Create a function from the function type

関数型から関数を作る機能。
なのですが、チュートリアルプロジェクトだと net/http が import できていないがために関数定義が読み取れずサジェストが効いていないです。
Create a function from the function type.gif
ので、go get -t "net/http" で入れて再録。
今度はちゃんと「Create function 'handler'」が出ました。
Create a function from the function type2.gif

以上です。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0