LoginSignup
10
2

More than 3 years have passed since last update.

error messageにコロンをつけたらlintに怒られた

Posted at

Goを書いている時に怒られて何のことかわからなかったので、調べた覚書です。

起こったこと

errors.New("Not found.")

サンプルの記述ですが、上記の記述だと、下記のメッセージが出て記述を直すように言われます。

error strings should not be capitalized or end with punctuation or a newline

エラーの文字列は大文字にしたり、句点、改行で終わらせたらいけないらしいです。
なぜ、そんな事になっているのか気になったので、公式のwikiで調べました。

Error strings should not be capitalized (unless beginning with proper nouns or acronyms) or end with punctuation, since they are usually printed following other context.

このメッセージだけじゃないからということみたいです。

結果

以下のように直しました。

errors.New("not found")

単純でしたが、色々作法があるんだなと。
記事を読んでいると、lintの設定次第なようなので、調整していくものなのかも。
https://kakakakakku.hatenablog.com/entry/2017/08/18/193946

10
2
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
10
2