Skip to content

Commit

Permalink
fix(psqlutil): bump deps add ConnectionConfig struct
Browse files Browse the repository at this point in the history
  • Loading branch information
bradub committed Jan 26, 2024
1 parent efdac65 commit b88b5fa
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 186 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ linters-settings:

goconst:
min-len: 2 # minimal length of string constant
min-occurrences: 2 # minimal occurrences count to trigger
min-occurrences: 4 # minimal occurrences count to trigger

gocritic:
enabled-tags:
Expand Down
30 changes: 30 additions & 0 deletions psqlutil/dsn.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,37 @@ import (
"fmt"
)

// ConnectionConfig is a PostgreSQL connection configuration.
type ConnectionConfig struct {
Host string
Port string
User string
Password string
DBName string
SSLMode string
}

// DSN returns a PostgreSQL Data Source Name.
func (c ConnectionConfig) DSN() string {
return fmt.Sprintf(
"host=%s "+
"user=%s "+
"password=%s "+
"dbname=%s "+
"port=%s "+
"sslmode=%s",
c.Host,
c.User,
c.Password,
c.DBName,
c.Port,
c.SSLMode,
)
}

// ComposeDSN returns a PostgreSQL Data Source Name.
//
// Deprecated: Use github.com/purposeinplay/go-commons/psqlutil.ConnectionConfig instead.
func ComposeDSN(
host,
port,
Expand Down
16 changes: 5 additions & 11 deletions psqlutil/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,21 @@ go 1.19

require (
github.com/avast/retry-go v3.0.0+incompatible
github.com/jackc/pgx/v4 v4.18.1
github.com/jackc/pgx/v5 v5.5.2
go.uber.org/zap v1.26.0
gorm.io/driver/postgres v1.5.4
gorm.io/gorm v1.25.5
gorm.io/gorm v1.25.6
moul.io/zapgorm2 v1.3.0
)

require (
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
github.com/jackc/pgconn v1.14.1 // indirect
github.com/jackc/pgio v1.0.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgproto3/v2 v2.3.2 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jackc/pgtype v1.14.0 // indirect
github.com/jackc/pgx/v5 v5.5.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9 // indirect
github.com/jackc/puddle/v2 v2.2.1 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.15.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/crypto v0.18.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/text v0.14.0 // indirect
)
Loading

0 comments on commit b88b5fa

Please sign in to comment.