Skip to content

Sup3r-Us3r/go-container-pattern

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Container Pattern

Container Pattern

Overview

This application implements the Container Pattern.

  • Container Pattern
  • Fiber
  • Postgres
  • Gorm

Container pattern

A Container is an object created to hold other objects that are accessed, this way injecting a dependency is very easy.

The repositories receive the database, and this database is injected as a dependency in each repository.

The services receive the repositories and these repositories are injected as a dependency on each service.

The handlers/controllers receive these services and each handler/controller is given the necessary service.

This pattern helps a lot, in addition to maintaining an organization, it guarantees a very high consistency in your codebase.

container-pattern

Install dependencies

$ go mod tidy

Configure .env

Fill the .env file with the correct values to connect to the Postgresql database.

$ cp .env.example .env

Run app

$ go run cmd/api/main.go

Now send a POST request to verify that the body data has been saved:

http://localhost:3333/installment

{
  "id": "1",
  "value": 10.1,
  "due_day": 30
}

About

This application implements the Container Pattern

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published