Categorygithub.com/dargasht/gocrud
repositorypackage
0.0.0-20250108000632-4dc1058d97ce
Repository: https://github.com/dargasht/gocrud.git
Documentation: pkg.go.dev

# README

gocrud

Template for go crud applications we use. Also some generic handler functions and helpers we use.

Installation

go get github.com/dargasht/gocrud

What we use

  • go-fiber for http server
  • pgx/v5 for database
  • pgxpool for database connection pool
  • sonic for json marshall/unmarshall
  • zap for logging
  • sqlc for database code generation
  • sqlc for some wierd queries that can't be done with sqlc
  • goose for database migrations

what we enjoy

  • excessive use of postgres json_agg function
  • simple architecture with no magic (maybe some magic, but not too much)
  • no ORM
  • writing raw sql queries
  • simplicity simplicity and simplicity

Folder structure

.
├── bin # for binaries (should be added in gitignore)
├── cfg # for configs
├── cmd
│   └── api
│       └── main.go # the main entry point
├── database
│   ├── migration # for database migrations
│   ├── query # for database queries
│   ├── repo # for sqlc generated queries and models 
│   └── store # for specific database implementations that uses sqlx
├── handler # for http handlers (data transformation and validation)
├── middleware # for http middlewares (if needed)
├── model # for service models and handler models (DTOs)
├── router # for instantiating handlers and injecting dependencies
├── service # for business logic (if needed)
└── utils # for utility functions 

Things to keep in mind:

  • services should be stateless and not depend on external services
  • use service layer if business logic is not simple otherwise use handler layer
  • go to each folder in the internal folder and read the README.md

Usefull stuff in this package are: