Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Clean Architecture using Go

Clean Architecture using Go

Presentation about Clean Architecture in Golang
Based on the post https://medium.com/@eminetto/clean-architecture-using-golang-b63587aa5e3f

Elton Minetto

March 03, 2020
Tweet

More Decks by Elton Minetto

Other Decks in Programming

Transcript

  1. Constraints • Independent of Frameworks • Testable • Independent of

    UI • Independent of Database • Independent of any external agent
  2. • Entities: encapsulate enterprise wide business rules. An entity in

    Go is a set of data structures and functions. • Use Cases: the software in this layer contains application specific business rules. It encapsulates and implements all of the use cases of the system.
  3. • Controller: a set of adapters that convert data from

    the format most convenient for the use cases and entities, to the format most convenient for some external agency such as the Database or the Web • Framework & Driver: this layer is generally composed of frameworks and tools such as the Database, the Web Framework, etc
  4. In the file interface.go we have the interfaces of Use

    Case and a repository, that will store our entities.
  5. In the files repository_inmem.go and repository_mongodb.go we have two implementations

    of repository interface. The repository represents the layer Framework & Driver
  6. Now we can add other controllers, like a CLI app,

    lambda functions, bots, and so on.