Skip to content

Commit e1f93da

Browse files
Merge pull request #9 from laironacosta/feature/packages
Feature/packages
2 parents 7ce7f19 + 6e9fe7e commit e1f93da

File tree

10 files changed

+38
-19
lines changed

10 files changed

+38
-19
lines changed

README.md

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,39 @@
1-
# Database: Postgresql, Redis, etc.
2-
This project shows the implementation of clients for postgresql, Redis and other databases in Golang.
1+
# Kit
2+
Set of common packages used by all or most projects in my repositories.
33

44
## Table of Contents
55

6-
- [Implementation](#implementation)
6+
- [Implementation examples](#implementation-examples)
77
- [Postgresql](#postgresql)
88
- [Redis](#redis)
9+
- [Testing](#testing)
910

10-
## Implementation
11+
## Implementation examples
1112

1213
### Postgresql
1314

14-
See the examples already implemented in the folder `/pgdb`.
15+
See the examples already implemented in the folder `/postgresql`.
1516

1617
### Redis
1718

18-
See the examples already implemented in the folder `/redisdb`.
19+
See the examples already implemented in the folder `/redis`.
20+
21+
### Testing
22+
23+
To run the tests simply execute the following command:
24+
25+
```shell
26+
make test
27+
```
28+
29+
This will stop any containers defined by the compose file for tests if already running
30+
and then rebuild the containers using the compose file.
31+
32+
To down the containers simply execute the following command:
33+
34+
```shell
35+
make test-down
36+
```
37+
38+
lairon14@gmail.com
39+
-- Lairon

go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module github.com/Lairon/db-go
1+
module github.com/laironacosta/kit-go
22

33
go 1.16
44

@@ -7,5 +7,4 @@ require (
77
github.com/go-redis/redis/v8 v8.8.0
88
github.com/sirupsen/logrus v1.8.1
99
github.com/stretchr/testify v1.7.0
10-
golang.org/x/sys v0.0.0-20210402192133-700132347e07 // indirect
1110
)

go.sum

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,8 @@ golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7w
132132
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
133133
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
134134
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
135+
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4 h1:EZ2mChiOa8udjfp6rRmswTbtZN/QzUQp4ptM4rnjHvc=
135136
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
136-
golang.org/x/sys v0.0.0-20210402192133-700132347e07 h1:4k6HsQjxj6hVMsI2Vf0yKlzt5lXxZsMW1q0zaq2k8zY=
137-
golang.org/x/sys v0.0.0-20210402192133-700132347e07/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
138137
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
139138
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
140139
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
File renamed without changes.

pgdb/example2/example2.go renamed to postgresql/example2/example2.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package main
22

33
import (
4-
"github.com/Lairon/db-go/pgdb"
54
"github.com/go-pg/pg/v10"
65
"github.com/go-pg/pg/v10/orm"
6+
pgKit "github.com/laironacosta/kit-go/postgresql"
77
log "github.com/sirupsen/logrus"
88
)
99

@@ -33,7 +33,7 @@ func main() {
3333

3434
func NewPgClient() *PgClient {
3535
return &PgClient{
36-
db: pgdb.NewPgDB(&pg.Options{
36+
db: pgKit.NewPgDB(&pg.Options{
3737
User: "root",
3838
Password: "root",
3939
Database: "db-test",

pgdb/pg_db.go renamed to postgresql/pg.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package pgdb
1+
package postgresql
22

33
import (
44
"github.com/go-pg/pg/v10"

pgdb/pg_db_test.go renamed to postgresql/pg_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package pgdb
1+
package postgresql
22

33
import (
44
"github.com/go-pg/pg/v10"

redisdb/example1/example1.go renamed to redis/example1/example1.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package main
22

33
import (
44
"context"
5-
"github.com/Lairon/db-go/redisdb"
65
"github.com/go-redis/redis/v8"
6+
redisKit "github.com/laironacosta/kit-go/redis"
77
log "github.com/sirupsen/logrus"
88
"time"
99
)
@@ -29,7 +29,7 @@ func main() {
2929

3030
func NewRedisClient() *RedisClient {
3131
return &RedisClient{
32-
db: redisdb.NewRedisDB(&redis.Options{
32+
db: redisKit.NewRedisDB(&redis.Options{
3333
Addr: "redis-test:6379",
3434
Password: "", // no password set
3535
DB: 0, // use default DB

redisdb/redis_db.go renamed to redis/redis.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package redisdb
1+
package redis
22

33
import (
44
"context"

redisdb/redis_db_test.go renamed to redis/redis_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package redisdb
1+
package redis
22

33
import (
44
"github.com/go-redis/redis/v8"
@@ -7,7 +7,7 @@ import (
77
)
88

99
var redisOptions = &redis.Options{
10-
Addr: "redis:6379",
10+
Addr: "redis-test:6379",
1111
Password: "",
1212
DB: 0,
1313
}

0 commit comments

Comments
 (0)