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
July 25, 2024
Programming
0
330
【Go言語】オプション設定のベストプラクティス
Go言語のオプション設定方法について、解説しています。
【Qiita】
【Go言語】オプション設定のベストプラクティス
Tomoki Ota
July 25, 2024
Tweet
Share
More Decks by Tomoki Ota
See All by Tomoki Ota
アーキテクチャの価値
tomo1227
0
89
アーキテクチャとビジネスロジック
tomo1227
0
87
【Go言語】テスト
tomo1227
0
51
【Go言語】クロージャ
tomo1227
0
250
【Go言語】イテレータ
tomo1227
0
67
【Go言語】エラーハンドリング
tomo1227
0
56
AIに淘汰されないようにするには?
tomo1227
0
57
【Go言語】range
tomo1227
0
60
【Go言語】break
tomo1227
0
59
Other Decks in Programming
See All in Programming
1から理解するWeb Push
dora1998
7
1.9k
ぬるぬる動かせ! Riveでアニメーション実装🐾
kno3a87
1
210
Processing Gem ベースの、2D レトロゲームエンジンの開発
tokujiros
2
120
アセットのコンパイルについて
ojun9
0
120
@Environment(\.keyPath)那么好我不允许你们不知道! / atEnvironment keyPath is so good and you should know it!
lovee
0
120
テストカバレッジ100%を10年続けて得られた学びと品質
mottyzzz
2
590
速いWebフレームワークを作る
yusukebe
5
1.7k
パッケージ設計の黒魔術/Kyoto.go#63
lufia
3
430
時間軸から考えるTerraformを使う理由と留意点
fufuhu
15
4.7k
Compose Multiplatform × AI で作る、次世代アプリ開発支援ツールの設計と実装
thagikura
0
140
print("Hello, World")
eddie
2
530
今から始めるClaude Code入門〜AIコーディングエージェントの歴史と導入〜
nokomoro3
0
110
Featured
See All Featured
How GitHub (no longer) Works
holman
315
140k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
30
9.7k
Designing for Performance
lara
610
69k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
8
520
Intergalactic Javascript Robots from Outer Space
tanoku
272
27k
GraphQLの誤解/rethinking-graphql
sonatard
72
11k
Mobile First: as difficult as doing things right
swwweet
224
9.9k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
48
9.7k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
33
2.4k
Why Our Code Smells
bkeepers
PRO
339
57k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
61k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
51
5.6k
Transcript
Tomoki Ota ʲGoݴޠʳΦϓγϣϯઃఆͷϕετϓϥΫςΟε
HTTPαʔόͷ࡞ 2
HTTPαʔόͷ࡞ 3
GinͷNew() 4
ᶃγϯϓϧͳΦϓγϣϯઃఆ ᶄCon f igߏମ ᶅBuilderύλʔϯ ᶆؔΦϓγϣϯύλʔϯ ᶇDysfunctional Options Pattern ᶈ݁
ΞδΣϯμ
γϯϓϧͳΦϓγϣϯઃఆํ๏
7 γϯϓϧͳઃఆํ๏
γϯϓϧͳઃఆํ๏ debugͷઃఆΛՃ͢Δ
HTTPαʔόͷ࡞ 9 ΫϥΠΞϯτଆͰҾ͕Γͳͯ͘յΕΔ
γϯϓϧͳઃఆํ๏
Con f igߏମ
Con f igߏମ
Con f igߏମ 13
Con f igߏମ 14
Con f igߏମ 15
ࢦఆ͠ͳ͔ͬͨύϥϝʔλʹθϩ͕ೖΔ(ҙ ਤతʹ0Λೖͨ͠ͷ͔ɺະೖྗͳͷ͔ͷҧ͍͕ ͔Βͳ͍) Con f igߏମͷσϝϦοτ
ࢦఆ͠ͳ͔ͬͨύϥϝʔλʹθϩ͕ೖΔ(ҙ ਤతʹ0Λೖͨ͠ͷ͔ɺະೖྗͳͷ͔ͷҧ͍͕ ͔Βͳ͍) Con f igߏମͷσϝϦοτ ϙΠϯλΛ͏
Con f igߏମͷσϝϦοτ ϙΠϯλΛ͏
Con f igߏମͷσϝϦοτ σϑΥϧτΛ͏߹ۭΛ͢ඞཁ͕͋Δ
Builderύλʔϯ
Builderύλʔϯͱʁ GoFͷσβΠϯύλʔϯͷ̍ͭ ॊೈੑͷߴ͍ղܾࡦΛఏڙ͠ɺՄಡੑΛߴΊΔ
Builderύλʔϯ 22
Builderύλʔϯ 23
Builderύλʔϯ 24
Builderύλʔϯ GOʹJavaͷ@BuilderΑ͏ͳຐ๏ͳ͍ GoFͷσβΠϯύλʔϯͷ̍ͭͰ͋ΔBuilderύλʔϯ Λ༻͍Δ͜ͱͰɺॊೈੑͷߴ͍ղܾࡦΛఏڙ͞ΕΔɻ Builderύλʔϯͷॻ͖ํෳ͋Δɻ
Builderύλʔϯ 26
Builderύλʔϯ
BuilderύλʔϯͷσϝϦοτ Con f igߏମಉ༷ɺσϑΥϧτͷઃఆΛ༻͍ͨ͠߹ ۭͷߏମΛ͢ඞཁ͕͋Γɺݟӫ͕͑ѱ͍
ؔΦϓγϣϯύλʔϯ
Functional Optional Pattern ؔΦϓγϣϯύλʔϯՄมݸҾʹґଘ ͢Δ ؔΦϓγϣϯύλʔϯͱʁ
ؔΦϓγϣϯύλʔϯͱʁ
ؔΦϓγϣϯύλʔϯͱʁ
ؔΦϓγϣϯύλʔϯͱʁ σϑΥϧτΛઃఆ͍ͨ͠߹ઃఆ͢Δඞཁ͕ͳ͍
Dysfunctional Options Pattern
ؔΦϓγϣϯύλʔϯத͕ؒଟ͘ɺෳࡶͰ ͋Δͱ͍͏͜ͱΛࢹͨ͠ύλʔϯ Dysfunctional Options Patternͱʁ
Dysfunctional Options Pattern
BulderύλʔϯͷҰͭ Dysfunctional Options Patternͱʁ
Dysfunctional Options Patternͱʁ ނʹɺσϑΥϧτΛ༻͍ͨ͠߹ɺۭͷߏମΛ͢ඞཁ͕͋Γ·͢ɻ ނʹɺσϑΥϧτΛ༻͍ͨ͠߹ɺۭͷߏମΛ͞ͳ͚ΕͳΒͳ͍
݁
GoͰҰ൪׳༻తͰ·ΕΔͷɺؔΦϓγϣϯύλʔϯ Builderύλʔϯ࣮͍͕͢͠ɺσϑΥϧτΛઃఆ͢Δ ͱ͖ʹɺJavaͱҧͬͯบ͕͋Δ ݁
GoͰҰ൪׳༻తͰ·ΕΔͷɺؔΦϓγϣϯύλʔϯɻ Builderύλʔϯ࣮͍͚͢͠ͲɺJavaͱҧ͍ɺগ͠บ͕͋Γ· ͢ɻ ݁