Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Goでのレシーバーとnilの関係 / Receiver and nil relationshi...
Search
Kentaro Kawano
July 26, 2019
Programming
540
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Goでのレシーバーとnilの関係 / Receiver and nil relationship in Go
Kentaro Kawano
July 26, 2019
More Decks by Kentaro Kawano
See All by Kentaro Kawano
Starting Python
kawaken
0
160
Goの時刻に関するテスト/Testing time in Go
kawaken
0
160
AWS Lambda + Go
kawaken
0
150
goaのdesignをラクに書く/Write goa design easily
kawaken
0
140
Goでのチーム開発とコード管理の悩み/Team development and code management in Go
kawaken
0
140
Pyvmomiとansibleのdynamic inventory
kawaken
0
150
Other Decks in Programming
See All in Programming
AGENTS.md Is Not Enough:Build Skills, Don't Download Them
lx_t
0
120
Go × SIMDで高速化するベクトル検索 ~ルーフラインモデルでSIMDが効く境界を探れ! ~
po3rin
1
1.3k
wkhtmltopdfの次どうするか問題2026
willnet
1
850
setup-vp GitLab対応の裏側
naokihaba
0
100
技術的負債の返済は、AI時代の複利で効く投資 — 経営としての意思決定とその遂行
curekoshimizu
0
1.4k
新卒PdEのリアル
ryu1013
1
500
更なる可用性を求めて、5年間運用したKotlinのアプリケーションをGoでリプレイスする話
ken_tunc
0
260
Omarchy Tokyo やると聞いて UMPC 買ってセットアップしてきた
mtsmfm
0
140
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
400
手動確認はもう限界 〜XCUITestでCustom URL Schemeの遷移を起動種別ごとに自動テストする〜 / Testing Custom URL Schemes with XCUITest
otouto
0
290
速く作れる。その次は、速く確かめられる開発へ 〜AIネイティブ開発を支える、Shift Down〜 / Can build fast. Next, moving to development where we can verify fast.
rkaga
4
3.1k
{ Android | Kotlin } Gradle Plugin in 2026
ryunen344
1
320
Featured
See All Featured
A Tale of Four Properties
chriscoyier
163
24k
Typedesign – Prime Four
hannesfritz
42
3.2k
Agile that works and the tools we love
rasmusluckow
331
22k
Code Reviewing Like a Champion
maltzj
528
40k
Everyday Curiosity
cassininazir
0
320
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.1k
Practical Orchestrator
shlominoach
192
12k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
700
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
240
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
1
410
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
330
Transcript
Goでのレシーバとnilの関係 2019-07-26 Umeda.go 2019 Summer Kentaro Kawano
レシーバとは • メソッド呼び出しの対象 • 値レシーバ • ポインタレシーバ
None
レシーバがnilのメソッド呼び出しはpanicになる?
None
必ずpanicになるとは限らない レシーバがnilのメソッド呼び出しはpanicになる?
メソッド式 • RecieverType.MethodName での呼び出しが可能 • user.SayHi() は (*User).SayHi(user) と同じ •
レシーバはメソッド式の第⼀引数になる
None
どんな時にpanicする?
間接参照するとき • ポインタ型の変数(値はnil)に対して • フィールドを参照するとき • 値レシーバが必要なメソッドを呼び出すとき • 変数はレシーバの型に応じて⾃動的に型が変換される
None
None
ダメな実装例
None
⼤事なところではnilチェックをちゃんとしよう
まとめ • レシーバには値レシーバとポインタレシーバがある • レシーバはメソッド式の第⼀引数 • レシーバがnilでもpanicしないケースがある • ポインタレシーバを利⽤する場合にはnilチェックする •
すべてのメソッドでチェックする必要はない(経験則