Following the discussions we had so far and also adding some learnings from this repo https://github.com/golang-standards/project-layout. I did the following changes
-
pkg
folder on root level contains all the packages we want to make publicly available. i.e. http/grpc clients or some common util lib -
internal
has some new folderspkg
,usecase
andentities
-
pkg
will contain all the libs we are going to use and create wrappers around it if needed to make code agnostic of vendors. -
entities
are acting as DTO objects - @akundu -
usecase
where you will aggregate your business logic from different services. a use case can granular or can grouped in multiple functions (in current code file will be used as a group). @akundu
-
-
factory.go
is a file which is added in folder where we need to create objects for external use. if needed this will return objects to all internal packages and will only take the dependencies which are not available in current or any of the child packages. (think of a tree) -
service
folder will contain domain specific packages (which are flat) -
cmd
is used to handle all the communication we will have from outer traffic. we can define different protocols as an outer layer and call the use cases which does the actual work. -
cmd/server/http
contains the http server definition using gin-gonic lib and handles all the network layer logic.