Thanks for the great sharing! BTW, one thing I've noticed is that all the structs under api folder are using non-pointer fields. For example, why wouldn't we write PostRoute like this:
PostRoute
type PostRoute struct { Controller *controller.PostController Handler *infrastructure.GinRouter }
And as a result, we can do main.go like below (using references):
main.go
func main() { router := infrastructure.NewGinRouter() db := infrastructure.NewDatabase() postRepository := repository.NewPostRepository(&db) postService := service.NewPostService(&postRepository) postController := controller.NewPostController(&postService) postRoute := routes.NewPostRoute(&postController, &router) postRoute.Setup() db.DB.AutoMigrate(&models.Post{}) router.Gin.Run(":8080") }
Again, thanks for sharing!
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks for the great sharing! BTW, one thing I've noticed is that all the structs under api folder are using non-pointer fields. For example, why wouldn't we write
PostRoute
like this:And as a result, we can do
main.go
like below (using references):Again, thanks for sharing!