bxcodec / go-clean-arch

Go (Golang) Clean Architecture based on Reading Uncle Bob's Clean Architecture
MIT License
9.22k stars 1.22k forks source link

Question about directory layer #69

Open ben-swit opened 2 years ago

ben-swit commented 2 years ago

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?

Ajilagi commented 2 years ago

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