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
-
pkgfolder on root level contains all the packages we want to make publicly available. i.e. http/grpc clients or some common util lib -
internalhas some new folderspkg,usecaseandentities-
pkgwill contain all the libs we are going to use and create wrappers around it if needed to make code agnostic of vendors. -
entitiesare acting as DTO objects - @akundu -
usecasewhere 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.gois 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) -
servicefolder will contain domain specific packages (which are flat) -
cmdis 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/httpcontains the http server definition using gin-gonic lib and handles all the network layer logic.