-
Notifications
You must be signed in to change notification settings - Fork 2
feat: Google Wireを使った依存性注入の導入 #1011
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Google Wireで依存性注入を自動化するためにリファクタリングを実施したよ✨
- Wire v0.6.0導入で手動DIを宣言的に置き換え!やばたにえん💖
- Controller/Repository/UseCase各層にwire.goを追加&wire_gen.goでコード生成🛠️
- main.goやテスト、MakefileもInitializeServer呼び出しへ対応&wire-genコマンド追加🎉
Reviewed Changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| api/internals/di/wire.go | Wire用injector定義を追加してInitializeServerを生成可能に |
| api/internals/di/wire_gen.go | 手動DIのコードをWire生成コードに置き換え |
| api/internals/usecase/wire.go | UseCase層のProviderセットを追加 |
| api/externals/repository/wire.go | Repository層のProviderセットを追加 |
| api/externals/controller/wire.go | Controller層のProviderセットを追加 |
| api/main.go | InitializeServer呼び出し&panic/CloseDB処理をWire対応に変更 |
| api/test/sample_test.go | テストコードをWire対応にリファクタリング |
| api/go.mod | Wire導入に伴うgo.mod更新 |
| Makefile | wire-gen & go-mod-tidyコマンドを追加 |
Comments suppressed due to low confidence (1)
api/go.mod:77
- このプロジェクトで
github.com/google/subcommandsパッケージを使用している箇所が見当たらないから、不要な依存として削除したほうがコードがすっきりするよ✂️
github.com/google/subcommands v1.2.0 // indirect
Kubosaka
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ぱっと見良さそう
APIの作成するときの手順とかざっくりメモっとくと良さそう
README.mdでいいか
対応Issue
resolve #0
概要
Google Wireを使った依存性注入システムを導入し、従来の手動による依存性注入を自動化しました。
主な変更点
make wire-genコマンドを追加し、wire_gen.goの生成を自動化技術的な改善
下記雑な図
画面スクリーンショット等
http://localhost:1323/- アプリケーションの基本的な動作確認※画面表示に変更はありません
テスト項目
make wire-genコマンドでwire_gen.goが正常に生成されることmake run)curl -s http://localhost:1323/)備考