diff --git a/README.md b/README.md index f04499e..5bc6543 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,39 @@ -# Database: Postgresql, Redis, etc. -This project shows the implementation of clients for postgresql, Redis and other databases in Golang. +# Kit +Set of common packages used by all or most projects in my repositories. ## Table of Contents -- [Implementation](#implementation) +- [Implementation examples](#implementation-examples) - [Postgresql](#postgresql) - [Redis](#redis) +- [Testing](#testing) -## Implementation +## Implementation examples ### Postgresql -See the examples already implemented in the folder `/pgdb`. +See the examples already implemented in the folder `/postgresql`. ### Redis -See the examples already implemented in the folder `/redisdb`. \ No newline at end of file +See the examples already implemented in the folder `/redis`. + +### Testing + +To run the tests simply execute the following command: + +```shell +make test +``` + +This will stop any containers defined by the compose file for tests if already running +and then rebuild the containers using the compose file. + +To down the containers simply execute the following command: + +```shell +make test-down +``` + +lairon14@gmail.com +-- Lairon \ No newline at end of file diff --git a/go.mod b/go.mod index 4bf5a85..b5938fd 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/Lairon/db-go +module github.com/laironacosta/kit-go go 1.16 @@ -7,5 +7,4 @@ require ( github.com/go-redis/redis/v8 v8.8.0 github.com/sirupsen/logrus v1.8.1 github.com/stretchr/testify v1.7.0 - golang.org/x/sys v0.0.0-20210402192133-700132347e07 // indirect ) diff --git a/go.sum b/go.sum index ad2501b..ab96ec1 100644 --- a/go.sum +++ b/go.sum @@ -132,9 +132,8 @@ golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4 h1:EZ2mChiOa8udjfp6rRmswTbtZN/QzUQp4ptM4rnjHvc= golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210402192133-700132347e07 h1:4k6HsQjxj6hVMsI2Vf0yKlzt5lXxZsMW1q0zaq2k8zY= -golang.org/x/sys v0.0.0-20210402192133-700132347e07/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= diff --git a/pgdb/example1/example1.go b/postgresql/example1/example1.go similarity index 100% rename from pgdb/example1/example1.go rename to postgresql/example1/example1.go diff --git a/pgdb/example2/example2.go b/postgresql/example2/example2.go similarity index 95% rename from pgdb/example2/example2.go rename to postgresql/example2/example2.go index 60e274a..21f8b26 100644 --- a/pgdb/example2/example2.go +++ b/postgresql/example2/example2.go @@ -1,9 +1,9 @@ package main import ( - "github.com/Lairon/db-go/pgdb" "github.com/go-pg/pg/v10" "github.com/go-pg/pg/v10/orm" + pgKit "github.com/laironacosta/kit-go/postgresql" log "github.com/sirupsen/logrus" ) @@ -33,7 +33,7 @@ func main() { func NewPgClient() *PgClient { return &PgClient{ - db: pgdb.NewPgDB(&pg.Options{ + db: pgKit.NewPgDB(&pg.Options{ User: "root", Password: "root", Database: "db-test", diff --git a/pgdb/pg_db.go b/postgresql/pg.go similarity index 97% rename from pgdb/pg_db.go rename to postgresql/pg.go index 7987901..defaca3 100644 --- a/pgdb/pg_db.go +++ b/postgresql/pg.go @@ -1,4 +1,4 @@ -package pgdb +package postgresql import ( "github.com/go-pg/pg/v10" diff --git a/pgdb/pg_db_test.go b/postgresql/pg_test.go similarity index 96% rename from pgdb/pg_db_test.go rename to postgresql/pg_test.go index 1373911..1fc18d2 100644 --- a/pgdb/pg_db_test.go +++ b/postgresql/pg_test.go @@ -1,4 +1,4 @@ -package pgdb +package postgresql import ( "github.com/go-pg/pg/v10" diff --git a/redisdb/example1/example1.go b/redis/example1/example1.go similarity index 91% rename from redisdb/example1/example1.go rename to redis/example1/example1.go index 0095bf6..26acbe8 100644 --- a/redisdb/example1/example1.go +++ b/redis/example1/example1.go @@ -2,8 +2,8 @@ package main import ( "context" - "github.com/Lairon/db-go/redisdb" "github.com/go-redis/redis/v8" + redisKit "github.com/laironacosta/kit-go/redis" log "github.com/sirupsen/logrus" "time" ) @@ -29,7 +29,7 @@ func main() { func NewRedisClient() *RedisClient { return &RedisClient{ - db: redisdb.NewRedisDB(&redis.Options{ + db: redisKit.NewRedisDB(&redis.Options{ Addr: "redis-test:6379", Password: "", // no password set DB: 0, // use default DB diff --git a/redisdb/redis_db.go b/redis/redis.go similarity index 97% rename from redisdb/redis_db.go rename to redis/redis.go index 7054668..e1ef59b 100644 --- a/redisdb/redis_db.go +++ b/redis/redis.go @@ -1,4 +1,4 @@ -package redisdb +package redis import ( "context" diff --git a/redisdb/redis_db_test.go b/redis/redis_test.go similarity index 91% rename from redisdb/redis_db_test.go rename to redis/redis_test.go index 198b244..f4bcbb6 100644 --- a/redisdb/redis_db_test.go +++ b/redis/redis_test.go @@ -1,4 +1,4 @@ -package redisdb +package redis import ( "github.com/go-redis/redis/v8" @@ -7,7 +7,7 @@ import ( ) var redisOptions = &redis.Options{ - Addr: "redis:6379", + Addr: "redis-test:6379", Password: "", DB: 0, }