Skip to content

Commit

Permalink
Make constructor return concrete type (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunboyy authored Feb 27, 2024
1 parent 4992f43 commit 7bb44ba
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion internal/mongo/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ func (g RepositoryGenerator) GenerateConstructor() (codegen.FunctionBuilder, err
},
},
Returns: []code.Type{
code.SimpleType(g.InterfaceName),
code.PointerType{
ContainedType: code.SimpleType(g.repoImplStructName()),
},
},
Body: codegen.FunctionBody{
codegen.ReturnStatement{
Expand Down
2 changes: 1 addition & 1 deletion test/generator_test_expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"go.mongodb.org/mongo-driver/mongo/options"
)

func NewUserRepository(collection *mongo.Collection) UserRepository {
func NewUserRepository(collection *mongo.Collection) *UserRepositoryMongo {
return &UserRepositoryMongo{
collection: collection,
}
Expand Down

0 comments on commit 7bb44ba

Please sign in to comment.