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でする場合に不要な Interfaceは消しやがれ
Search
garebare
June 17, 2022
Programming
160
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
クリーンアーキテクチャ をGoでする場合に不要な Interfaceは消しやがれ
6月17日に行われたNEWDEBUG!!!!で発表した史料です。
https://caspur.wintu.dev/front/lives/264
garebare
June 17, 2022
More Decks by garebare
See All by garebare
ペンギンをおすすめする
garebareda
0
62
hey-techcamp-2022
garebareda
2
81
Rustで作った自作コマンド群の話
garebareda
0
190
自作Git作った話
garebareda
3
880
Rustで自作言語のインタプリタ作って Webで動くようにした話
garebareda
0
880
Vtuberをやりたくなりました
garebareda
1
94
Other Decks in Programming
See All in Programming
GraphQL の onError と Nullability のこれから
quramy
0
160
IBM Bob でAI駆動開発『QC-Playbook』
ichirokano2
0
120
Agentic Software Factoryに、すごく賢いIF文を。 / super smart IF statement into the Agentic Software Factory.
rkaga
8
2.3k
Next.js: The final boss of Web Performance
guaca
0
310
オーケストレーション記述言語 Katari
yukikurage
0
170
HTML-in-Canvasで作る未来のWeb UI表現
clockmaker
5
5.2k
AIで開発が速くなった先で、開発チームは何を目指すか
shihochan
1
1.7k
[2026-10-14](C)Re:ゼロから始める異世界生活〜始まりの終わりと終わりの始まり〜
tosite
0
140
ソニーのクラウド共通基盤の変遷とAI時代の開発スタイルに合わせた進化 / The Journey of Sony’s Common Cloud Platform and Its Evolution for AI-Native Development
kenjiyoneyama
0
290
AmebaブログはKMPから卒業します
kmars0605
0
220
エージェントを使い続けるためのメタワーク / Meta-work for keeping using the agent
rkaga
6
1.6k
🇪🇸 React Alicante 2026 (Workshop)
ythecombinator
PRO
0
100
Featured
See All Featured
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2.1k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
530
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.6k
4 Signs Your Business is Dying
shpigford
187
23k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
The Limits of Empathy - UXLibs8
cassininazir
2
730
Designing for Timeless Needs
cassininazir
1
530
sira's awesome portfolio website redesign presentation
elsirapls
0
460
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
500
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
280
Claude Code のすすめ
schroneko
67
230k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
1
570
Transcript
クリーンアーキテクチャを Goでする場合に不要な Interfaceは消しやがれ @garebare521
By たふみ神
ということで考えて行こうと思います
クリーンアーキテクチャとは
Entity UseCase Cotroller UI DB
なんかこういうやつ!
Interfaceで依存を逆転させてるらしい
実装例 type Hoge struct { … } type HogeUsecase struct
{ … } type HogeRepository struct { …. } type Hoge Controller struct { … }
実装例 hogeRepo:=NewHogeRepository() hogeUse :=NewHogeUsecase(hogeRepo) hogeCtrl := NewHogeCtroller(hogeUse)
実装例 hogeCtrl.Post () hogeUse.Post () HogeRepo.Insert()
Interfaceなしだと モックが作れないので テストし難い
Interface書くしかない
クリーンアーキテクチャを Goでする場合に不要な Interfaceは消しやがれ
じゃあどうするか
とりあえず実装量が少なそうな UseCase層を取り除く
Entity UseCase Cotroller UI DB
Entity Cotroller UI DB
単純にインターフェースを削除すると テストが破綻する
テストしやすい形にしたい
じゃあもう実態持たせる必要なくない?
Entity UI DB Controller
Entity UI DB Controller こうしたい
実態を持たせずに Interfaceと同じようなことをしたい
関数を引数に渡せばよくね????
関数を渡すようにするとテストも書きやすい
HogeController func (c *hogeCtrl) Post(c Context, insert func(hoge Hoge) (error))
{ insert() } hogeCtrl.Post(c, hogeRepo.insert)
関数の引数をInterface代わりにして 解決!
ただ必要な関数が増えるたびに 引数も増えます