go-clean-arch
go-clean-arch copied to clipboard
Question about directory layer
hi @bxcodec thank for your source
i got a lot of help
I want to know why I classified each directory under the domain.
like
article
├── delivery
│ └── http
│ ├── article_handler.go
│ ├── article_test.go
│ └── middleware
│ ├── middleware.go
│ └── middleware_test.go
├── repository
│ ├── helper.go
│ └── mysql
│ ├── mysql_article.go
│ └── mysqlarticle_test.go
└── usecase
├── article_ucase.go
└── article_ucase_test.go
to
article
├── article_handler.go
├── article_test.go
├── article_ucase.go
├── article_ucase_test.go
├── mysql_article.go
└── mysqlarticle_test.go
why i think this needs, when developing have to open many folders
and this sample usefull msa?
I agree with your thought @ben-swit. I prefer to put all of them into one package, so we only need article package, and it's easier to use article.NewHandler(), article.NewUsecase(), article.NewRepo(), and anything about article instead of using each of handler, usecase, etc. It also prevents nested packaging and aliasing like the one in below
https://github.com/bxcodec/go-clean-arch/blob/4cbd13bf0726ce654dce4ed0aee7bd0854511223/app/main.go#L14-L18