Multiple databases support #62
-
Hello Ben, Thanks for sharing these great resources! Would it be good approach inject DB/API service handler into UserService ? Thank you, Deividas |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @deividaspetraitis. If the package sqlite
type UserService struct {
AuthService myapp.AuthService
} Then I'd attach the concrete implementation in the |
Beta Was this translation helpful? Give feedback.
Hi @deividaspetraitis. If the
sqlite.UserService
needed to interact with anAuthService
then I'd probably attach it as a field onsqlite.UserService
:Then I'd attach the concrete implementation in the
cmd/myapp/main.go
so that the sqlite implementation wouldn't need to know anything about the other database implementation.