Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
命名をリントする
Search
chiroruxx
December 15, 2024
Programming
1
770
命名をリントする
2024/12/15 Kyoto.go #56 で発表した資料です。
chiroruxx
December 15, 2024
Tweet
Share
More Decks by chiroruxx
See All by chiroruxx
Go Connectへの想い
chiroruxx
0
160
eBPF with PHPをさわる
chiroruxx
0
120
sl完全に理解したつもり
chiroruxx
0
99
良い命名かを調べるリンターを作った + α
chiroruxx
0
100
GoLandを布教する会
chiroruxx
0
35
PHPはいつから死んでいるかの調査
chiroruxx
3
650
元phperから見たGoの良いところ
chiroruxx
0
92
Go Connectへの想い
chiroruxx
0
480
GraphQLに入門してみた
chiroruxx
2
340
Other Decks in Programming
See All in Programming
Datadog RUM 本番導入までの道
shinter61
1
260
「兵法」から見る質とスピード
ickx
0
260
実はすごいスピードで進化しているCSS
hayato_yokoyama
0
110
FormFlow - Build Stunning Multistep Forms
yceruto
1
160
ワイがおすすめする新潟の食 / 20250530phpconf-niigata-eve
kasacchiful
0
300
Benchmark
sysong
0
140
[初登壇@jAZUG]アプリ開発者が気になるGoogleCloud/Azure+wasm/wasi
asaringo
0
130
UPDATEがシステムを複雑にする? イミュータブルデータモデルのすすめ
shimomura
1
530
C++20 射影変換
faithandbrave
0
430
List Unfolding - 'unfold' as the Computational Dual of 'fold', and how 'unfold' relates to 'iterate'"
philipschwarz
PRO
0
190
Beyond Portability: Live Migration for Evolving WebAssembly Workloads
chikuwait
0
350
Haskell でアルゴリズムを抽象化する / 関数型言語で競技プログラミング
naoya
17
4.2k
Featured
See All Featured
Rails Girls Zürich Keynote
gr2m
94
14k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
Build The Right Thing And Hit Your Dates
maggiecrowley
36
2.7k
Stop Working from a Prison Cell
hatefulcrawdad
269
20k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
20
1.3k
Raft: Consensus for Rubyists
vanstee
139
7k
Become a Pro
speakerdeck
PRO
28
5.4k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
16
920
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
8
650
Art, The Web, and Tiny UX
lynnandtonic
299
21k
VelocityConf: Rendering Performance Case Studies
addyosmani
329
24k
Transcript
命名をリントする 2024/12/15 Kyoto.go #56
自己紹介 ちひろ 株式会社モリサワ X: @chiroruxxxx
1年をカンファレンスに 例えるなら
年末のLTは
懇親会LTのような ものですよね!?!?
ということで 明日からすぐに役に立たない! 身にならない話をします!
本題
命名をリントする 2024/12/15 Kyoto.go #56
良い命名とは 観点は色々とある 時間をかけ、一生懸命考えた命名は良い命名かもしれない 人生の中で、一番命名を気にしているタイミングがどこだろ う
良い命名とは 子どもの名付け
子どもの 名付け 子どもの名づけも、色々な観点がある 言葉の意味 子どもがどうなってほしいか よびやすさ・語感
周りから浮かないか 画数
画数占い 赤ちゃん命名ガイド
つまり
良い命名とは 良い画数の命名 かもしれない?
命名と画数 画数の良い命名を変数にすれば その変数が起因のバグが起こらない かもしれない?
われわれは 画数をチェックする 必要がある! ということでつくりました
作ったよ https://github.com/chiroruxx/lucky-lint-go go vet で動くよ 以下の命名に対応
変数・定数の宣言・代入 型 フィールド名 関数名 パッケージのエイリアス名
ドメイン部分 「ローマ字の姓名判断・商品名画数」を参考に https://meimeimaker.com/articles/strokes-alphabet.php
ドメイン部分 「ローマ字の姓名判断・商品名画数」を参考に https://meimeimaker.com/articles/strokes-alphabet.php
こんなかんじ
まとめ 良い画数の名前を選ぼう! CIでリンターをまわしてチェックすれば安全だね!
その他細かい話 時間があれば
予約語 予約語の命名は開発者がどうにもできないので除外 変数名の _ (アンダーバー) 関数名の
main init ドットインポート
慣用的な名前 変数名の ok, err メソッドのレシーバ名 1文字にすることが多いが、1文字はたいてい良い画数ではない
見るべき ノード asciicheck では、ast.Ident のみを対象としている ast.Ident を対象とすると、自分の定義していない命名も 見てしまう
例えば Printf は ast.Ident だが、開発者が定義してない 細かく見ていく必要がある