Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build/ci: Update Go to v1.24, golangci-lint to v1.64.5 and fix issues #1804

Merged
merged 8 commits into from
Mar 10, 2025
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/amd64.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.23-alpine
FROM golang:1.24-alpine

# Install GCC and musl-dev (needed for SQLite library)
RUN apk add --no-cache gcc musl-dev
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.23.x'
go-version: '1.24.x'
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.60.1
version: v1.64.6
2 changes: 1 addition & 1 deletion .github/workflows/proto-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.23.x
go-version: 1.24.x

- name: Setup build depends
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
on: [push, pull_request]
name: CI
env:
GO_VERSION: 1.23.x
GO_VERSION: 1.24.x
jobs:
backend:
name: GoCryptoTrader backend (${{ matrix.os }}, ${{ matrix.goarch }}, psql=${{ matrix.psql }}, skip_wrapper_tests=${{ matrix.skip_wrapper_tests}}, sonic=${{ matrix.sonic && matrix.goarch != '386' }})
Expand Down
14 changes: 3 additions & 11 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ linters:
# - errorlint
# - exhaustive
# - exhaustruct
- exportloopref
# - exptostd
- fatcontext
# - forbidigo
- forcetypeassert
Expand Down Expand Up @@ -100,7 +100,7 @@ linters:
- stylecheck
- tagalign
# - tagliatelle
- tenv
# - tenv # Duplicate feature of another linter. Replaced by usetesting.
- testableexamples
- testifylint
# - testpackage
Expand All @@ -109,6 +109,7 @@ linters:
- unconvert
- unparam
- usestdlibvars
# - usetesting # Disabled temporarily due to the number of t.Context changes required
# - varnamelen
- wastedassign
- whitespace
Expand Down Expand Up @@ -163,21 +164,12 @@ issues:
- text: 'shadow: declaration of "err" shadows declaration at'
linters: [ govet ]


exclude-dirs:
- vendor
- web/
- testdata
- database/models/

# List of regexps of issue texts to exclude, empty list by default.
# But independently from this option we use default exclude patterns,
# it can be disabled by `exclude-use-default: false`. To list all
# excluded by default patterns execute `golangci-lint run --help`
exclude:
# The following silences false positives in table tests
# https://github.com/kyoh86/scopelint/issues/4
- Using the variable on range scope `ti` in function literal
include:
- EXC0012 # revive: Comment exported (.+) should have comment( \(or a comment on this block\))? or be unexported
- EXC0014 # revive: Comment on exported (.+) should be of the form "(.+)..."
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.23 as build
FROM golang:1.24 as build
WORKDIR /go/src/github.com/thrasher-corp/gocryptotrader
COPY . .
RUN GO111MODULE=on go mod vendor
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
LDFLAGS = -ldflags "-w -s"
GCTPKG = github.com/thrasher-corp/gocryptotrader
LINTPKG = github.com/golangci/golangci-lint/cmd/golangci-lint@v1.60.1
LINTPKG = github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.6
LINTBIN = $(GOPATH)/bin/golangci-lint
GCTLISTENPORT=9050
GCTPROFILERLISTENPORT=8085
Expand Down
23 changes: 13 additions & 10 deletions backtester/btcli/commands.go
Original file line number Diff line number Diff line change
@@ -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"
)

Expand Down Expand Up @@ -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",
},
},
}
Expand Down Expand Up @@ -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(
Expand All @@ -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),
},
)

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down
Loading
Loading