bxcodec / go-clean-arch

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

Dependency Rule Followed? #16

Closed alok87 closed 5 years ago

alok87 commented 5 years ago

// Usecase represent the article's usecases type Usecase interface { Fetch(ctx context.Context, cursor string, num int64) ([]*models.Article, string, error)


- Repository layer imports models
```go
import (
    "context"

    "github.com/bxcodec/go-clean-arch/models"
)

// Repository represent the article's repository contract
type Repository interface {
    Fetch(ctx context.Context, cursor string, num int64) (res []*models.Article, nextCursor string, err error)

All the upper layers are referring to models(entities - innermost circle) - "github.com/bxcodec/go-clean-arch/models"

Question? As the layers does not look like concentric circles, so is the dependency rule followed?

bxcodec commented 5 years ago

Hi @alok87,

Thank for your question, Models are just a model. A blueprint of the data structure. And to avoid circular import between the package and to avoid redundant code of the struct-code, I decide to separate the models' struct into one package.