Skip to content
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

generated repository should return concrete type instead of interface #42

Closed
hhow09 opened this issue Feb 26, 2024 · 2 comments
Closed
Assignees

Comments

@hhow09
Copy link
Contributor

hhow09 commented Feb 26, 2024

Is your feature request related to a problem? Please describe.
generated repository should return concrete type instead of interface

currently NewUserRepository in example is returning interface.
However as suggestion in go codereview

Go interfaces generally belong in the package that uses values of the interface type, not the package that implements those values. The implementing package should return concrete (usually pointer or struct) types 1

*UserRepositoryMongo should be returned.

btw you can assert the implementation in test file

// user_repo_test.go
var _ UserRepository  = (*UserRepositoryMongo)(nil)

Describe the solution you'd like
return concrete type

Footnotes

  1. https://go.dev/wiki/CodeReviewComments#interfaces

@sunboyy
Copy link
Owner

sunboyy commented Feb 26, 2024

I see. I will work on it.

@sunboyy
Copy link
Owner

sunboyy commented Feb 27, 2024

Fixed by #44

@sunboyy sunboyy closed this as completed Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants