modernise: Run new gopls modernise tool against the codebase and fix minor issues (#1826)

* modernise: Run new gopls modernise tool against codebase

* Address shazbert's nits

* apichecker, gctcli: Simplify HTML scraping functions and improve depth limit handling

* refactor: Create minSyncInterval const and update order book limit handling for binance and binanceUS

* refactor: Various slice usage improvements and rename TODO

* tranches: Revert deleteByID changes due to performance decrease

Shazbert was a F1 driver in a past lifetime 🏎️

* tranches: Simply retrieve copy

Thanks to shazbert

* documentation: Sort contributors list by contributions

* tranches: Remove deadcode in deleteByID
This commit is contained in:
Adrian Gallagher
2025-03-21 09:17:10 +11:00
committed by GitHub
parent d857d704e3
commit 4651af5767
223 changed files with 1504 additions and 1752 deletions

View File

@@ -75,10 +75,10 @@ type IDatabase interface {
// without giving the receiver access to all functionality
type ISQL interface {
BeginTx(context.Context, *sql.TxOptions) (*sql.Tx, error)
Exec(string, ...interface{}) (sql.Result, error)
Query(string, ...interface{}) (*sql.Rows, error)
QueryRow(string, ...interface{}) *sql.Row
ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
QueryRowContext(context.Context, string, ...interface{}) *sql.Row
Exec(string, ...any) (sql.Result, error)
Query(string, ...any) (*sql.Rows, error)
QueryRow(string, ...any) *sql.Row
ExecContext(context.Context, string, ...any) (sql.Result, error)
QueryContext(context.Context, string, ...any) (*sql.Rows, error)
QueryRowContext(context.Context, string, ...any) *sql.Row
}

View File

@@ -61,7 +61,7 @@ func Event(id, msgtype, message string) {
}
// GetEvent () returns list of order events matching query
func GetEvent(startTime, endTime time.Time, order string, limit int) (interface{}, error) {
func GetEvent(startTime, endTime time.Time, order string, limit int) (any, error) {
if database.DB.SQL == nil {
return nil, database.ErrDatabaseSupportDisabled
}

View File

@@ -36,7 +36,7 @@ func TestAudit(t *testing.T) {
config *database.Config
runner func(t *testing.T)
closer func(dbConn *database.Instance) error
output interface{}
output any
}{
{
"SQLite-Write",

View File

@@ -48,7 +48,7 @@ func TestScript(t *testing.T) {
config *database.Config
runner func()
closer func(dbConn *database.Instance) error
output interface{}
output any
}{
{
"SQLite-Write",

View File

@@ -309,7 +309,7 @@ func getInRangeSQLite(exchangeName, assetType, base, quote string, startDate, en
if err != nil {
return nil, err
}
wheres := map[string]interface{}{
wheres := map[string]any{
"exchange_name_id": exchangeUUID,
"asset": strings.ToLower(assetType),
"base": strings.ToUpper(base),
@@ -351,7 +351,7 @@ func getInRangePostgres(exchangeName, assetType, base, quote string, startDate,
if err != nil {
return nil, err
}
wheres := map[string]interface{}{
wheres := map[string]any{
"exchange_name_id": exchangeUUID,
"asset": strings.ToLower(assetType),
"base": strings.ToUpper(base),
@@ -414,7 +414,7 @@ func DeleteTrades(trades ...Data) error {
}
func deleteTradesSQLite(ctx context.Context, tx *sql.Tx, trades ...Data) error {
tradeIDs := make([]interface{}, len(trades))
tradeIDs := make([]any, len(trades))
for i := range trades {
tradeIDs[i] = trades[i].ID
}
@@ -424,7 +424,7 @@ func deleteTradesSQLite(ctx context.Context, tx *sql.Tx, trades ...Data) error {
}
func deleteTradesPostgres(ctx context.Context, tx *sql.Tx, trades ...Data) error {
tradeIDs := make([]interface{}, len(trades))
tradeIDs := make([]any, len(trades))
for i := range trades {
tradeIDs[i] = trades[i].ID
}
@@ -433,7 +433,7 @@ func deleteTradesPostgres(ctx context.Context, tx *sql.Tx, trades ...Data) error
return err
}
func generateQuery(clauses map[string]interface{}, start, end time.Time, isSQLite bool) []qm.QueryMod {
func generateQuery(clauses map[string]any, start, end time.Time, isSQLite bool) []qm.QueryMod {
query := []qm.QueryMod{
qm.OrderBy("timestamp"),
}

View File

@@ -276,7 +276,7 @@ func generateWhereQuery(columns, id []string, limit int) []qm.QueryMod {
return queries
}
func generateWhereBetweenQuery(column string, start, end interface{}, limit int) []qm.QueryMod {
func generateWhereBetweenQuery(column string, start, end any, limit int) []qm.QueryMod {
return []qm.QueryMod{
qm.Limit(limit),
qm.Where(column+" BETWEEN ? AND ?", start, end),

View File

@@ -60,7 +60,7 @@ func TestWithdraw(t *testing.T) {
config *database.Config
runner func(t *testing.T)
closer func(dbConn *database.Instance) error
output interface{}
output any
}{
{
"SQLite-Write",

View File

@@ -35,7 +35,7 @@ func TestDatabaseConnect(t *testing.T) {
name string
config *database.Config
closer func(dbConn *database.Instance) error
output interface{}
output any
}{
{
"SQLite",