Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 27 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -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`.
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
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/Lairon/db-go
module github.com/laironacosta/kit-go

go 1.16

Expand All @@ -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
)
3 changes: 1 addition & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions pgdb/example2/example2.go → postgresql/example2/example2.go
Original file line number Diff line number Diff line change
@@ -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"
)

Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion pgdb/pg_db.go → postgresql/pg.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package pgdb
package postgresql

import (
"github.com/go-pg/pg/v10"
Expand Down
2 changes: 1 addition & 1 deletion pgdb/pg_db_test.go → postgresql/pg_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package pgdb
package postgresql

import (
"github.com/go-pg/pg/v10"
Expand Down
4 changes: 2 additions & 2 deletions redisdb/example1/example1.go → redis/example1/example1.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion redisdb/redis_db.go → redis/redis.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package redisdb
package redis

import (
"context"
Expand Down
4 changes: 2 additions & 2 deletions redisdb/redis_db_test.go → redis/redis_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package redisdb
package redis

import (
"github.com/go-redis/redis/v8"
Expand All @@ -7,7 +7,7 @@ import (
)

var redisOptions = &redis.Options{
Addr: "redis:6379",
Addr: "redis-test:6379",
Password: "",
DB: 0,
}
Expand Down