repository
0.0.0-20240210033011-86b690d7fb8e
Repository: https://github.com/jimeux/go-generic-dao.git
Documentation: pkg.go.dev
# README
go-generic-dao
Reducing database/sql
boilerplate using Go generics without the need for added dependencies.
Medium Article
For a full explanation of the code, please see the accompanying blog post.
Setup
Environment variables
Use direnv as below,
or manually set contents of .env
in your terminal or editor.
direnv allow
Database
docker-compose up -d
make db-init
Run tests
make test
Code Overview
config
package
- Initializes environment variables and stores them in a singleton
- Initialize with
config.Init()
- Access with
config.Instance()
db
package
- Initializes a database instance and stores it in a singleton
- Initialize with
db.Init()
- Access with
db.Instance()
test
package
- Provides helpers for testing
- Call
test.InitConfig()
instead ofconfig.Init()
fromTestMain
functions
like
and user
packages
- Contain entities, DAOs and tests