Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Code Directory V4
*ps I'm just updating this to my recent project structure. It may be different from the others, but it should be easy to learn as the first start before learning more techniques and pattern
New Code structure :
Changelogs
1. Declare Interface to the consuming side
Move all interfaces from
domain
to the consuming side. E.g., therest/article.go
layer depends on the service so that it will consume theArticleService
interface. Instead of referring to thedomain
, the interface will be declared in therest/article.go
package. The same goes for repositories interfaces that are declared inarticle/service.go
2. internal package
The
internal
package hides the service-specific detail implementation, e.g., database, rest, cache, etc. Moving this implementation tointernal
will hide the implementations if the project is imported from another project. But it still shows all the core logic (domain and service).3. Service-focused package
The
article
package will only contain all business logic related to the article domain <> in the previous version it contains all (service, repository, controller).And this package now will called as service layer.
Previously
New Structure