Skip to content

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

Merged
thrasher- merged 8 commits intothrasher-corp:masterfrom
thrasher-:go124_buildci
Mar 10, 2025
Merged

build/ci: Update Go to v1.24, golangci-lint to v1.64.5 and fix issues#1804
thrasher- merged 8 commits intothrasher-corp:masterfrom
thrasher-:go124_buildci

Conversation

@thrasher-
Copy link
Collaborator

@thrasher- thrasher- commented Feb 14, 2025

PR Description

Bumps Go to v1.24, golangci-lint to v1.64.5 and fixes the issues it found.

Summary of changes:

  • Linter complained for the benchmark for i := 0; i < b.N; i++ loops and suggested to use a range as is standard now, however I opted instead to use b.Loop() which is new in Go1.24.
  • assertify any things which were touched.
  • Resolved several integer overflow issues, with an attempt to unify all var usage across the codebase and reduce type casting where possible.
  • kline.CalculateCandleDateRanges had a potential divide by 0 panic bug if limit was set to 0.
  • Config AES CFB has been switched to AES GCM as the prior one has been deprecated.
  • Removed HitBTC v1 authenticated endpoints (API on version 3)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How has this been tested

  • go test ./... -race
  • golangci-lint run

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation and regenerated documentation via the documentation tool
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally and on Github Actions with my changes
  • Any dependent changes have been merged and published in downstream modules

@thrasher- thrasher- self-assigned this Feb 14, 2025
@thrasher- thrasher- added the review me This pull request is ready for review label Feb 14, 2025
@thrasher- thrasher- linked an issue Feb 14, 2025 that may be closed by this pull request
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 90 out of 105 changed files in this pull request and generated 1 comment.

Files not reviewed (15)
  • .github/workflows/arm64.Dockerfile: Language not supported
  • Dockerfile: Language not supported
  • Makefile: Language not supported
  • backtester/btrpc/btrpc.swagger.json: Language not supported
  • cmd/gctcli/data_history.go: Evaluated as low risk
  • backtester/data/kline/kline.go: Evaluated as low risk
  • backtester/btrpc/btrpc.proto: Evaluated as low risk
  • backtester/engine/setup.go: Evaluated as low risk
  • cmd/gen_sqlboiler_config/main.go: Evaluated as low risk
  • .github/workflows/linter.yml: Evaluated as low risk
  • backtester/engine/grpcserver_test.go: Evaluated as low risk
  • .github/workflows/proto-lint.yml: Evaluated as low risk
  • backtester/btrpc/btrpc_grpc.pb.go: Evaluated as low risk
  • backtester/engine/grpcserver.go: Evaluated as low risk
  • .github/workflows/tests.yml: Evaluated as low risk
Comments suppressed due to low confidence (2)

backtester/config/strategyconfigbuilder/main.go:432

  • Ensure that the port value is correctly handled as uint32 throughout the codebase to avoid potential overflow issues.
port, err = strconv.ParseUint(input, 10, 32)

backtester/config/strategyconfigbuilder/main.go:437

  • [nitpick] The comment //nolint:gosec // No overflow risk needs to be justified better. Ensure that there is indeed no overflow risk.
cfg.DataSettings.DatabaseData.Config.Port = uint32(port) //nolint:gosec // No overflow risk

}

var intervalOverride uint64
var intervalOverride int64
Copy link

Copilot AI Feb 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a check to ensure intervalOverride is not negative before converting it to time.Duration.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

@shazbert shazbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good stuff! nothing major I could see.

@thrasher- thrasher- force-pushed the go124_buildci branch 2 times, most recently from cdba415 to 27b8e73 Compare February 17, 2025 04:52
Copy link
Collaborator

@shazbert shazbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK tested old config encryption to this from master 🚀

@shazbert shazbert added the szrc shazbert review complete label Feb 18, 2025
@thrasher- thrasher- requested a review from gbjk February 24, 2025 03:03
Copy link
Collaborator

@gbjk gbjk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

Only nits, and a few pedantic suggestions.

@thrasher- thrasher- force-pushed the go124_buildci branch 2 times, most recently from 9c98fb6 to dee6f63 Compare February 28, 2025 10:50
Copy link
Collaborator

@gbjk gbjk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 👍

Copy link
Collaborator

@shazbert shazbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One suggestion changes look good.

Copy link
Collaborator

@gloriousCode gloriousCode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was a slog. Only thing that really stood out was usetesting being commented out

Copy link
Collaborator

@shazbert shazbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK new changes. 🚀

Copy link
Collaborator

@gloriousCode gloriousCode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK!

Copy link
Collaborator

@gbjk gbjk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉

Comment on lines +134 to +135
totalLen := len(encryptionPrefix) + len(c.storedSalt) + len(encryptionVersionPrefix) + versionSize + len(ciphertext)
appendedFile := make([]byte, totalLen)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm easy, but arguably:

Suggested change
totalLen := len(encryptionPrefix) + len(c.storedSalt) + len(encryptionVersionPrefix) + versionSize + len(ciphertext)
appendedFile := make([]byte, totalLen)
appendedFile := make([]byte, len(encryptionPrefix) + len(c.storedSalt) + len(encryptionVersionPrefix) + versionSize + len(ciphertext))

For me, it's very implicit that the maths there amounts to "total length"

Comment on lines +385 to +386
assert.NotEmpty(t, defaultCfg.Name)
assert.True(t, defaultCfg.Enabled)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that when you're not testing the overall thing, you have to add context for the error.
That is: require.NotEmpty(t, defaultCfg) is fine, because it's about the unit test's target func main return value.

Suggested change
assert.NotEmpty(t, defaultCfg.Name)
assert.True(t, defaultCfg.Enabled)
assert.NotEmpty(t, defaultCfg.Name, "Name should not be empty")
assert.True(t, defaultCfg.Enabled, "Enabled should have correct value")

@thrasher-
Copy link
Collaborator Author

This PR is pending release of sonic's next release: bytedance/sonic#741 (comment) which should land next week

@gbjk gbjk added nomerge requires dependency This pull request is dependent on another, so it can't be merged until the dependent one is merged and removed nomerge requires dependency This pull request is dependent on another, so it can't be merged until the dependent one is merged labels Mar 7, 2025
Copy link
Collaborator

@gbjk gbjk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Only Nits.

t.Errorf("received '%v' expected '%v'", resp, nil)
}
assert.ErrorIs(t, err, common.ErrNilPointer)
assert.Nil(t, resp)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦟 Don't think we should need to check what resp is when err is not nil 🙂

Suggested change
assert.Nil(t, resp)

h = new(dollarcostaverage.Strategy)
resp, err = createNewStrategy(dollarcostaverage.Name, true, h)
assert.NoError(t, err, "createNewStrategy should not error")
assert.NotNil(t, resp)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦟 Nit:

Suggested change
assert.NotNil(t, resp)
assert.NotSame(t, h, resp, "createNewStrategy must return a new pointer")

Copy link
Collaborator

@shazbert shazbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just something I noticed on new changes. Thanks!

Comment on lines +389 to +391
assert.Positive(t, defaultCfg.WebsocketResponseCheckTimeout, 0)
assert.Positive(t, defaultCfg.WebsocketResponseMaxLimit, 0)
assert.Positive(t, defaultCfg.WebsocketTrafficTimeout, 0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert.Positive(t, defaultCfg.WebsocketResponseCheckTimeout, 0)
assert.Positive(t, defaultCfg.WebsocketResponseMaxLimit, 0)
assert.Positive(t, defaultCfg.WebsocketTrafficTimeout, 0)
assert.Positive(t, defaultCfg.WebsocketResponseCheckTimeout)
assert.Positive(t, defaultCfg.WebsocketResponseMaxLimit)
assert.Positive(t, defaultCfg.WebsocketTrafficTimeout)

Copy link
Collaborator

@gbjk gbjk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉

Copy link
Collaborator

@shazbert shazbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lovely, thanks!

@thrasher- thrasher- merged commit d64d56f into thrasher-corp:master Mar 10, 2025
5 of 12 checks passed
@github-project-automation github-project-automation bot moved this from In review to Done in GoCryptoTrader Kanban Mar 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gcrc GloriousCode Review Complete review me This pull request is ready for review szrc shazbert review complete

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

build/ci: Upgrade to Go 1.24

5 participants