mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
Bump golangci-lint to v1.24.0, linter fixes and general code improvements (#478)
* Bump golangci-lint version, update Go version deps and generic code improvements * Fix wesbocket resp nil check and zip closures * Update pprof path
This commit is contained in:
@@ -9,12 +9,11 @@ import (
|
||||
"github.com/thrasher-corp/gocryptotrader/database/drivers"
|
||||
)
|
||||
|
||||
// Db holds all information for a database instance
|
||||
type Db struct {
|
||||
SQL *sql.DB
|
||||
DataPath string
|
||||
Config *Config
|
||||
|
||||
// Instance holds all information for a database instance
|
||||
type Instance struct {
|
||||
SQL *sql.DB
|
||||
DataPath string
|
||||
Config *Config
|
||||
Connected bool
|
||||
Mu sync.RWMutex
|
||||
}
|
||||
@@ -29,7 +28,7 @@ type Config struct {
|
||||
|
||||
var (
|
||||
// DB Global Database Connection
|
||||
DB = &Db{}
|
||||
DB = &Instance{}
|
||||
|
||||
// MigrationDir which folder to look in for current migrations
|
||||
MigrationDir = filepath.Join("..", "..", "database", "migrations")
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
// Connect opens a connection to Postgres database and returns a pointer to database.DB
|
||||
func Connect() (*database.Db, error) {
|
||||
func Connect() (*database.Instance, error) {
|
||||
if database.DB.Config.SSLMode == "" {
|
||||
database.DB.Config.SSLMode = "disable"
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
// Connect opens a connection to sqlite database and returns a pointer to database.DB
|
||||
func Connect() (*database.Db, error) {
|
||||
func Connect() (*database.Instance, error) {
|
||||
if database.DB.Config.Database == "" {
|
||||
return nil, database.ErrNoDatabaseProvided
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ func TestAudit(t *testing.T) {
|
||||
name string
|
||||
config *database.Config
|
||||
runner func(t *testing.T)
|
||||
closer func(dbConn *database.Db) error
|
||||
closer func(dbConn *database.Instance) error
|
||||
output interface{}
|
||||
}{
|
||||
{
|
||||
|
||||
@@ -41,7 +41,7 @@ func TestScript(t *testing.T) {
|
||||
name string
|
||||
config *database.Config
|
||||
runner func()
|
||||
closer func(dbConn *database.Db) error
|
||||
closer func(dbConn *database.Instance) error
|
||||
output interface{}
|
||||
}{
|
||||
{
|
||||
|
||||
@@ -20,6 +20,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
// ErrNoResults is the error returned if no results are found
|
||||
ErrNoResults = errors.New("no results found")
|
||||
)
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ func TestWithdraw(t *testing.T) {
|
||||
name string
|
||||
config *database.Config
|
||||
runner func(t *testing.T)
|
||||
closer func(dbConn *database.Db) error
|
||||
closer func(dbConn *database.Instance) error
|
||||
output interface{}
|
||||
}{
|
||||
{
|
||||
|
||||
@@ -66,7 +66,7 @@ func GetConnectionDetails() *database.Config {
|
||||
}
|
||||
|
||||
// ConnectToDatabase opens connection to database and returns pointer to instance of database.DB
|
||||
func ConnectToDatabase(conn *database.Config) (dbConn *database.Db, err error) {
|
||||
func ConnectToDatabase(conn *database.Config) (dbConn *database.Instance, err error) {
|
||||
database.DB.Config = conn
|
||||
|
||||
if conn.Driver == database.DBPostgreSQL {
|
||||
@@ -87,7 +87,7 @@ func ConnectToDatabase(conn *database.Config) (dbConn *database.Db, err error) {
|
||||
}
|
||||
|
||||
// CloseDatabase closes database connection
|
||||
func CloseDatabase(conn *database.Db) (err error) {
|
||||
func CloseDatabase(conn *database.Instance) (err error) {
|
||||
if conn != nil {
|
||||
return conn.SQL.Close()
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ func TestDatabaseConnect(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
config *database.Config
|
||||
closer func(dbConn *database.Db) error
|
||||
closer func(dbConn *database.Instance) error
|
||||
output interface{}
|
||||
}{
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user