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
Tomoki Ota
August 02, 2024
Programming
0
29
【Go言語】名前付き戻り値
Go言語の名前付き戻り値の違いについて、解説しています。
【Qiita】
https://qiita.com/twrcd1227/items/2b6506ad57d3dc0b12d1
Tomoki Ota
August 02, 2024
Tweet
Share
More Decks by Tomoki Ota
See All by Tomoki Ota
アーキテクチャの価値
tomo1227
0
40
アーキテクチャとビジネスロジック
tomo1227
0
44
【Go言語】テスト
tomo1227
0
22
【Go言語】クロージャ
tomo1227
0
210
【Go言語】イテレータ
tomo1227
0
30
【Go言語】エラーハンドリング
tomo1227
0
33
AIに淘汰されないようにするには?
tomo1227
0
30
【Go言語】range
tomo1227
0
21
【Go言語】break
tomo1227
0
33
Other Decks in Programming
See All in Programming
Ruby on cygwin 2025-02
fd0
0
140
Pythonでもちょっとリッチな見た目のアプリを設計してみる
ueponx
1
560
Unity Android XR入門
sakutama_11
0
160
Lottieアニメーションをカスタマイズしてみた
tahia910
0
130
密集、ドキュメントのコロケーション with AWS Lambda
satoshi256kbyte
0
190
dbt Pythonモデルで実現するSnowflake活用術
trsnium
0
150
Rails アプリ地図考 Flush Cut
makicamel
1
120
社内フレームワークとその依存性解決 / in-house framework and its dependency management
vvakame
1
560
CSS Linter による Baseline サポートの仕組み
ryo_manba
1
100
『品質』という言葉が嫌いな理由
korimu
0
160
動作確認やテストで漏れがちな観点3選
starfish719
6
1k
CI改善もDatadogとともに
taumu
0
120
Featured
See All Featured
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.2k
Agile that works and the tools we love
rasmusluckow
328
21k
Thoughts on Productivity
jonyablonski
69
4.5k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
114
50k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
30
2.2k
GraphQLの誤解/rethinking-graphql
sonatard
68
10k
The World Runs on Bad Software
bkeepers
PRO
67
11k
GitHub's CSS Performance
jonrohan
1030
460k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
27
1.9k
The Cost Of JavaScript in 2023
addyosmani
47
7.3k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.7k
Practical Orchestrator
shlominoach
186
10k
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