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
【Go言語】名前付き戻り値
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Tomoki Ota
August 02, 2024
Programming
57
0
Share
【Go言語】名前付き戻り値
Go言語の名前付き戻り値の違いについて、解説しています。
【Qiita】
https://qiita.com/twrcd1227/items/2b6506ad57d3dc0b12d1
Tomoki Ota
August 02, 2024
More Decks by Tomoki Ota
See All by Tomoki Ota
アーキテクチャの価値
tomo1227
0
120
アーキテクチャとビジネスロジック
tomo1227
0
120
【Go言語】テスト
tomo1227
0
80
【Go言語】クロージャ
tomo1227
0
310
【Go言語】イテレータ
tomo1227
0
100
【Go言語】エラーハンドリング
tomo1227
0
83
AIに淘汰されないようにするには?
tomo1227
0
82
【Go言語】range
tomo1227
0
91
【Go言語】break
tomo1227
0
82
Other Decks in Programming
See All in Programming
The free-lunch guide to idea circularity
hollycummins
0
400
Kubernetesでセルフホストが簡単なNewSQLを求めて / Seeking a NewSQL Database That's Simple to Self-Host on Kubernetes
nnaka2992
0
190
Codex CLIのSubagentsによる並列API実装 / Parallel API Implementation with Codex CLI Subagents
takatty
2
760
コードレビューをしない選択 #でぃーぷらすトウキョウ
kajitack
3
1.2k
Strategy for Finding a Problem for OSS: With Real Examples
kibitan
0
130
AI 開発合宿を通して得た学び
niftycorp
PRO
0
190
OTP を自動で入力する裏技
megabitsenmzq
0
130
「接続」—パフォーマンスチューニングの最後の一手 〜点と点を結ぶ、その一瞬のために〜
kentaroutakeda
5
2.4k
LM Linkで(非力な!)ノートPCでローカルLLM
seosoft
0
320
Understanding Apache Lucene - More than just full-text search
spinscale
0
150
生成 AI 時代のスナップショットテストってやつを見せてあげますよ(α版)
ojun9
0
330
PHP 7.4でもOpenTelemetryゼロコード計装がしたい! / PHPerKaigi 2026
arthur1
1
460
Featured
See All Featured
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
660
Designing for Performance
lara
611
70k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.1k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
1
1.5k
Color Theory Basics | Prateek | Gurzu
gurzu
0
270
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.4k
Designing for Timeless Needs
cassininazir
0
180
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
160
Music & Morning Musume
bryan
47
7.1k
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
340
The Limits of Empathy - UXLibs8
cassininazir
1
280
Transcript
Tomoki Ota ʲGoݴޠʳ໊લ͖Γ
໊લ͖Γͱʁ ໊લ͖Γͷ༻ྫ ແҙຯͳ໊લ͖Γ ՄಡੑҎ֎ͷ໊લ͖Γ ۭreturn ໊લ͖Γͷ෭࡞༻ ·ͱΊ ΞδΣϯμ
໊લ͖Γͱʁ
GoͰ໊લ͖Γ(Named Return Value) ͋·ΓΘΕͳ͍ ໊લ͖Γͱʁ
໊લ͖ΓΛ͏ͱɺҾͳ͠ͷۭreturnจΛݺͼग़ͤΔ ໊લ͖Γͱʁ
໊લ͖Γͷ༻ྫ
໊લ͖Γͷ༻ྫ
໊લ͖Γͷ༻ྫ
ແҙຯͳ໊લ͖Γ
ແҙຯͳ໊લ͖Γ errorܕ͕errorͰ͋Δ͜ͱࣗ໌
ՄಡੑҎ֎ͷ໊લ͖Γ
ՄಡੑҎ֎ͷ໊લ͖Γ
ՄಡੑҎ֎ͷ໊લ͖Γ
ۭreturn
ۭreturn ۭreturnҰൠతʹ͍ؔͰ༻͍ΒΕΔɻ ͍ؔͰ༻͢ΔͱɺՄಡੑ͕ѱ͘ͳΔͷͰɺ༻ ͖͢Ͱͳ͍ɻ
ۭreturn 1ͭͷؔͰɺۭreturnΛ͏͔ɺҾͷ͋Δ returnΛ༻͢Δ͔Ұ؏ੑΛอͭ͜ͱ͕େࣄɻ
໊લ͖Γͷ෭࡞༻
໊લ͖Γͷ෭࡞༻ ໊લ͖ΓɺθϩͰॳظԽ͞ΕΔͷͰɺҙਤ ͠ͳ͍όάΛট͘Մೳੑ͕͋Δ
໊લ͖Γͷ෭࡞༻ ઌ΄ͲͷgetCoordinatesΛ֦ ு͠ɺॅॴΛݕূͯ͠ɺ࠲ඪΛ औಘ͢Δɻ·ͨɺ్தͰɺί ϯςΩετͰɺσουϥΠϯ͕ ա͗ͯͳ͍͔Ωϟϯηϧ͞ Ε͍ͯͳ͍͔Λݕࠪ͢Δɻ
໊લ͖Γͷ෭࡞༻ if ctx.Err() != nilͰฦ͞ΕΤ ϥʔerr͕ͩɺerrʹԿ ೖ͓ͯ͠ΒͣɺθϩͰ͋Δ nil͔͠ฦ͞ͳ͍ɻ
໊લ͖Γͷ෭࡞༻ err໊લ͖ΓʹΑͬͯ ॳظԽ͍ͯ͠ΔͷͰɺ໊લ͖ Γ͕ͳ͚ΕɺίϯύΠϧ ΤϥʔͱͳΔɻ
ղܾ๏1
ղܾ๏2