mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-30 23:16:52 +00:00
build/ci: Update Go to v1.24, golangci-lint to v1.64.6 and fix issues (#1804)
* build/ci: Update Go to v1.24, golangci-lint to v1.64.5 and fix issues * Address shazbert's nitters * linter/config: Fix new linter issue and use versionSize const * Address gk's nitters and fix additional linter issue after rebase * Address glorious nits * staticcheck: Fix additional linter issues after upgrading to Go 1.24.1 and golangci-lint v1.64.6 Also addresses nits * Improve testing, assertify usage and use common.ErrParsingWSField * TestCreateNewStrategy: Replace must > should wording
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/thrasher-corp/gocryptotrader/backtester/btrpc"
|
||||
"github.com/thrasher-corp/gocryptotrader/backtester/config"
|
||||
"github.com/thrasher-corp/gocryptotrader/common"
|
||||
"github.com/urfave/cli/v2"
|
||||
"google.golang.org/protobuf/types/known/durationpb"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
)
|
||||
|
||||
@@ -49,10 +50,10 @@ var executeStrategyFromFileCommand = &cli.Command{
|
||||
Aliases: []string{"e"},
|
||||
Usage: fmt.Sprintf("override the strategy file's end time using your local time. eg '%v'", time.Now().Truncate(time.Hour).Format(time.DateTime)),
|
||||
},
|
||||
&cli.Uint64Flag{
|
||||
&cli.DurationFlag{
|
||||
Name: "intervaloverride",
|
||||
Aliases: []string{"i"},
|
||||
Usage: "override the strategy file's candle interval, in seconds. eg 60 = 1 minute",
|
||||
Usage: "override the strategy file's candle interval in the format of a time duration. eg '1m' for 1 minute",
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -118,16 +119,18 @@ func executeStrategyFromFile(c *cli.Context) error {
|
||||
}
|
||||
}
|
||||
|
||||
var intervalOverride uint64
|
||||
var intervalOverride time.Duration
|
||||
if c.IsSet("intervaloverride") {
|
||||
intervalOverride = c.Uint64("intervaloverride")
|
||||
intervalOverride = c.Duration("intervaloverride")
|
||||
} else if c.Args().Get(5) != "" {
|
||||
intervalOverride, err = strconv.ParseUint(c.Args().Get(5), 10, 64)
|
||||
intervalOverride, err = time.ParseDuration(c.Args().Get(5))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
overrideDuration := time.Duration(intervalOverride) * time.Second
|
||||
if intervalOverride < 0 {
|
||||
return errors.New("interval override duration cannot be less than 0")
|
||||
}
|
||||
|
||||
client := btrpc.NewBacktesterServiceClient(conn)
|
||||
result, err := client.ExecuteStrategyFromFile(
|
||||
@@ -138,7 +141,7 @@ func executeStrategyFromFile(c *cli.Context) error {
|
||||
DoNotStore: dns,
|
||||
StartTimeOverride: timestamppb.New(s),
|
||||
EndTimeOverride: timestamppb.New(e),
|
||||
IntervalOverride: uint64(overrideDuration),
|
||||
IntervalOverride: durationpb.New(intervalOverride),
|
||||
},
|
||||
)
|
||||
|
||||
@@ -503,7 +506,7 @@ func executeStrategyFromConfig(c *cli.Context) error {
|
||||
}
|
||||
|
||||
dataSettings := &btrpc.DataSettings{
|
||||
Interval: uint64(defaultConfig.DataSettings.Interval.Duration().Nanoseconds()),
|
||||
Interval: durationpb.New(defaultConfig.DataSettings.Interval.Duration()),
|
||||
Datatype: defaultConfig.DataSettings.DataType,
|
||||
}
|
||||
if defaultConfig.DataSettings.APIData != nil {
|
||||
@@ -546,7 +549,7 @@ func executeStrategyFromConfig(c *cli.Context) error {
|
||||
if defaultConfig.DataSettings.DatabaseData != nil {
|
||||
dbConnectionDetails := &btrpc.DatabaseConnectionDetails{
|
||||
Host: defaultConfig.DataSettings.DatabaseData.Config.Host,
|
||||
Port: uint32(defaultConfig.DataSettings.DatabaseData.Config.Port),
|
||||
Port: defaultConfig.DataSettings.DatabaseData.Config.Port,
|
||||
Password: defaultConfig.DataSettings.DatabaseData.Config.Password,
|
||||
Database: defaultConfig.DataSettings.DatabaseData.Config.Database,
|
||||
SslMode: defaultConfig.DataSettings.DatabaseData.Config.SSLMode,
|
||||
|
||||
Reference in New Issue
Block a user