diff --git a/internal/mongo/generator.go b/internal/mongo/generator.go index 26c040e..44437a1 100644 --- a/internal/mongo/generator.go +++ b/internal/mongo/generator.go @@ -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{ diff --git a/test/generator_test_expected.txt b/test/generator_test_expected.txt index d8385ad..4b23b95 100644 --- a/test/generator_test_expected.txt +++ b/test/generator_test_expected.txt @@ -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, }