From 5b6c38db80fc1ca355c20322035f0f47b2641764 Mon Sep 17 00:00:00 2001 From: Fedor Partanskiy Date: Mon, 16 Feb 2026 20:54:00 +0300 Subject: [PATCH] bump go to 1.26.0 Signed-off-by: Fedor Partanskiy --- .github/workflows/go.yml | 6 +++--- .github/workflows/release.yml | 2 +- .github/workflows/vulnerability-scan.yml | 4 ++-- .golangci.yml | 3 ++- chrobot/chrobot.go | 10 ++++++---- go.mod | 2 +- hlf/hlfexecutor.go | 2 +- hlf/sdkwrapper/service/crypto.go | 3 ++- hlf/sdkwrapper/service/fabric.go | 12 +++++------- storage/redis/storage.go | 4 ++-- test/integration/chexec/chexec_test.go | 2 +- test/integration/go.mod | 2 +- test/unit/batch_test.go | 2 +- test/unit/chcollector_bench_test.go | 2 +- test/unit/chcollector_test.go | 14 +++++++------- test/unit/chrobot_test.go | 6 +++--- test/unit/dto_models_test.go | 14 +++++++------- test/unit/loader_test.go | 2 +- test/unit/stub_stor_test.go | 5 ++--- 19 files changed, 49 insertions(+), 48 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index e453f1d..21462d9 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -8,7 +8,7 @@ on: workflow_dispatch: env: - GO_VER: 1.25.7 + GO_VER: 1.26.0 GINKGO_VER: 2.27.3 jobs: @@ -54,9 +54,9 @@ jobs: go-version: ${{ env.GO_VER }} cache: false - name: golangci-lint - uses: golangci/golangci-lint-action@v7 + uses: golangci/golangci-lint-action@v9 with: - version: v2.4 + version: v2.9.0 skip-cache: true problem-matchers: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f8b8aa4..23093b6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,7 +7,7 @@ on: - 'v*' env: - GO_VER: 1.25.7 + GO_VER: 1.26.0 UBUNTU_VER: 22.04 APP_VER: ${{ github.ref_name }} diff --git a/.github/workflows/vulnerability-scan.yml b/.github/workflows/vulnerability-scan.yml index df21ffb..224a4fc 100644 --- a/.github/workflows/vulnerability-scan.yml +++ b/.github/workflows/vulnerability-scan.yml @@ -22,7 +22,7 @@ permissions: jobs: scan-scheduled: if: ${{ github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} - uses: "google/osv-scanner-action/.github/workflows/osv-scanner-reusable.yml@v2.2.2" + uses: "google/osv-scanner-action/.github/workflows/osv-scanner-reusable.yml@v2.3.3" with: scan-args: |- --config ./osv-scanner-config.toml @@ -31,7 +31,7 @@ jobs: scan-pr: if: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }} - uses: "google/osv-scanner-action/.github/workflows/osv-scanner-reusable-pr.yml@v2.2.2" + uses: "google/osv-scanner-action/.github/workflows/osv-scanner-reusable-pr.yml@v2.3.3" with: scan-args: |- --config ./osv-scanner-config.toml diff --git a/.golangci.yml b/.golangci.yml index 29a769d..3923ecf 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,7 +1,7 @@ version: "2" run: concurrency: 4 - go: "1.25" + go: "1.26" tests: false linters: default: none @@ -56,6 +56,7 @@ linters: - unparam - usestdlibvars - whitespace + - modernize settings: gosec: excludes: diff --git a/chrobot/chrobot.go b/chrobot/chrobot.go index db0f7ce..fc8eb64 100644 --- a/chrobot/chrobot.go +++ b/chrobot/chrobot.go @@ -3,6 +3,7 @@ package chrobot import ( "context" "fmt" + "strings" "time" "github.com/anoideaopen/glog" @@ -352,12 +353,13 @@ func batchExecInfoMsg(chName string, bfe *executordto.Batch, batchInfo *collecto } func storedCheckpointsMsg(checkPoints *stordto.ChCheckPoint) string { - msg := "saved checkpoints:\n" + var msg strings.Builder + msg.WriteString("saved checkpoints:\n") for ch, n := range checkPoints.SrcCollectFromBlockNums { - msg += fmt.Sprintf("collect from %d block for channel %s\n", n, ch) + msg.WriteString(fmt.Sprintf("collect from %d block for channel %s\n", n, ch)) } - msg += fmt.Sprintf("exec on peers with minimum blocknum in ledger %d\n", checkPoints.MinExecBlockNum) - return msg + msg.WriteString(fmt.Sprintf("exec on peers with minimum blocknum in ledger %d\n", checkPoints.MinExecBlockNum)) + return msg.String() } // CreateRobots - creates robots specified by config diff --git a/go.mod b/go.mod index a37c52d..f7caa8b 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/anoideaopen/robot -go 1.25.7 +go 1.26.0 require ( github.com/anoideaopen/common-component v0.0.7 diff --git a/hlf/hlfexecutor.go b/hlf/hlfexecutor.go index ddae2bc..19ec587 100644 --- a/hlf/hlfexecutor.go +++ b/hlf/hlfexecutor.go @@ -25,7 +25,7 @@ type hlfExecutor struct { } func (he *hlfExecutor) Execute(ctx context.Context, request channel.Request) (channel.Response, error) { - var options []channel.RequestOption + options := make([]channel.RequestOption, 0, 2) executeTimeout := he.chCtx.EndpointConfig().Timeout(fab.Execute) if he.execOpts.ExecuteTimeout > 0 { diff --git a/hlf/sdkwrapper/service/crypto.go b/hlf/sdkwrapper/service/crypto.go index c84aff6..0380508 100755 --- a/hlf/sdkwrapper/service/crypto.go +++ b/hlf/sdkwrapper/service/crypto.go @@ -184,7 +184,8 @@ func SignACL(signerInfoArray []SignerInfo, methodName string, address string, re nonce := GetNonce() // 1. update to change any transactions // 2. - result := []string{methodName, address, reason, reasonID, newPkey, nonce} + result := make([]string, 0, len(signerInfoArray)+6) + result = append(result, methodName, address, reason, reasonID, newPkey, nonce) for _, signerInfo := range signerInfoArray { result = append(result, ConvertPublicKeyToBase58(signerInfo.PublicKey)) } diff --git a/hlf/sdkwrapper/service/fabric.go b/hlf/sdkwrapper/service/fabric.go index 77f372f..f7fee03 100644 --- a/hlf/sdkwrapper/service/fabric.go +++ b/hlf/sdkwrapper/service/fabric.go @@ -218,7 +218,7 @@ func (hlf *HLFClient) Invoke(channelID string, chaincodeName string, methodName client := channelConnection.channelClient - var beforeInvokeData interface{} + var beforeInvokeData any if hlf.beforeInvokeHandler != nil { beforeInvokeData, err = hlf.beforeInvokeHandler(channelID, chaincodeName, methodName, methodArgs, noBatch, peers...) if err != nil { @@ -247,8 +247,8 @@ func (hlf *HLFClient) Invoke(channelID string, chaincodeName string, methodName } type ( - HlfBeforeInvokeHandler func(channelID string, chaincodeName string, methodName string, methodArgs []string, noBatch bool, peers ...string) (interface{}, error) - HlfAfterInvokeHandler func(beforeInvokeData interface{}, r *channel.Response, invokeErr error, channelID string, chaincodeName string, methodName string, methodArgs []string, noBatch bool, peers ...string) error + HlfBeforeInvokeHandler func(channelID string, chaincodeName string, methodName string, methodArgs []string, noBatch bool, peers ...string) (any, error) + HlfAfterInvokeHandler func(beforeInvokeData any, r *channel.Response, invokeErr error, channelID string, chaincodeName string, methodName string, methodArgs []string, noBatch bool, peers ...string) error ) func (hlf *HLFClient) Request( @@ -270,11 +270,9 @@ func (hlf *HLFClient) Request( return nil, err } - batchWaiter.Add(1) - go func() { - defer batchWaiter.Done() + batchWaiter.Go(func() { waitBatchAndPrintContents(notifier) - }() + }) } printInvokeArgs(methodArgs, chaincodeName, methodName) diff --git a/storage/redis/storage.go b/storage/redis/storage.go index 6386c9c..17eb796 100644 --- a/storage/redis/storage.go +++ b/storage/redis/storage.go @@ -161,7 +161,7 @@ func (stor *Storage) RemoveAllData(ctx context.Context) error { return res.Err() } -func encodeData(data interface{}) ([]byte, error) { +func encodeData(data any) ([]byte, error) { var bytebuffer bytes.Buffer e := gob.NewEncoder(&bytebuffer) if err := e.Encode(data); err != nil { @@ -173,7 +173,7 @@ func encodeData(data interface{}) ([]byte, error) { return bytebuffer.Bytes(), nil } -func decodeData(data []byte, res interface{}) error { +func decodeData(data []byte, res any) error { bytebuffer := bytes.NewBuffer(data) d := gob.NewDecoder(bytebuffer) if err := d.Decode(res); err != nil { diff --git a/test/integration/chexec/chexec_test.go b/test/integration/chexec/chexec_test.go index 1c0efbd..39e9f2e 100644 --- a/test/integration/chexec/chexec_test.go +++ b/test/integration/chexec/chexec_test.go @@ -143,7 +143,7 @@ var _ = Describe("Robot channel executor tests", func() { Expect(err).NotTo(HaveOccurred()) var preimages [][]byte - for i := 0; i < 3; i++ { + for range 3 { txID, err := ntesting.EmitFiat(context.Background(), fiatOwner, user1, 1, ciData.HlfFiatChannel, ciData.HlfFiatChannel) Expect(err).NotTo(HaveOccurred()) diff --git a/test/integration/go.mod b/test/integration/go.mod index 67d52b7..c99a7c8 100644 --- a/test/integration/go.mod +++ b/test/integration/go.mod @@ -1,6 +1,6 @@ module github.com/anoideaopen/robot/test/integration -go 1.25.7 +go 1.26.0 tool ( github.com/IBM/idemix/tools/idemixgen diff --git a/test/unit/batch_test.go b/test/unit/batch_test.go index c065159..a035c5b 100644 --- a/test/unit/batch_test.go +++ b/test/unit/batch_test.go @@ -125,7 +125,7 @@ func TestBasicBehavior(t *testing.T) { require.NotNil(t, b) addBlocks := func(chName string, fbn, bc int) { - for i := 0; i < bc; i++ { + for i := range bc { if chName == ch1Name { ok, err := b.AddIfInLimit(chName, &collectordto.BlockData{ BlockNum: uint64(i + fbn), diff --git a/test/unit/chcollector_bench_test.go b/test/unit/chcollector_bench_test.go index f60fa04..168eb67 100644 --- a/test/unit/chcollector_bench_test.go +++ b/test/unit/chcollector_bench_test.go @@ -29,7 +29,7 @@ func collectNBlocks(b *testing.B, totalCountBlocks int, bufSize uint) { for i := 0; i < b.N; i++ { events := make(chan *fab.BlockEvent, totalCountBlocks) - for i := 0; i < totalCountBlocks; i++ { + for range totalCountBlocks { events <- &fab.BlockEvent{Block: &common.Block{}} } diff --git a/test/unit/chcollector_test.go b/test/unit/chcollector_test.go index 7d1097a..2027c7d 100644 --- a/test/unit/chcollector_test.go +++ b/test/unit/chcollector_test.go @@ -76,7 +76,7 @@ func TestCollectingTheSameBlock(t *testing.T) { const totalCountBlocks = 2 // add two identical blocks with transactions to the event channel events := make(chan *fab.BlockEvent, totalCountBlocks) - for i := 0; i < totalCountBlocks; i++ { + for range totalCountBlocks { events <- &fab.BlockEvent{Block: bltx} } @@ -127,7 +127,7 @@ func TestCollectingTheSameBlockMultiswaps(t *testing.T) { const totalCountBlocks = 2 // add two identical blocks with transactions to the event channel events := make(chan *fab.BlockEvent, totalCountBlocks) - for i := 0; i < totalCountBlocks; i++ { + for range totalCountBlocks { events <- &fab.BlockEvent{Block: bltx} } @@ -178,7 +178,7 @@ func TestCollectingTheSameBlockKeys(t *testing.T) { const totalCountBlocks = 2 // add two identical blocks with transactions to the event channel events := make(chan *fab.BlockEvent, totalCountBlocks) - for i := 0; i < totalCountBlocks; i++ { + for range totalCountBlocks { events <- &fab.BlockEvent{Block: bltx} } @@ -229,7 +229,7 @@ func TestCollectingTheSameBlockMultikeys(t *testing.T) { const totalCountBlocks = 2 // add two identical blocks with transactions to the event channel events := make(chan *fab.BlockEvent, totalCountBlocks) - for i := 0; i < totalCountBlocks; i++ { + for range totalCountBlocks { events <- &fab.BlockEvent{Block: bltx} } @@ -280,7 +280,7 @@ func TestCollectingTheSameBlockSwaps(t *testing.T) { const totalCountBlocks = 2 // add two identical blocks with transactions to the event channel events := make(chan *fab.BlockEvent, totalCountBlocks) - for i := 0; i < totalCountBlocks; i++ { + for range totalCountBlocks { events <- &fab.BlockEvent{Block: bltx} } @@ -323,7 +323,7 @@ func TestSimpleWork(t *testing.T) { const totalCountBlocks = 100 events := make(chan *fab.BlockEvent, totalCountBlocks) - for i := 0; i < totalCountBlocks; i++ { + for i := range totalCountBlocks { events <- &fab.BlockEvent{Block: &common.Block{ Header: &common.BlockHeader{ Number: uint64(i), @@ -370,7 +370,7 @@ func TestCollectorWorkWithErrors(t *testing.T) { prsr.callHlp.AddErrMap(prsr.ExtractData, prsrErrors) events := make(chan *fab.BlockEvent, totalCountBlocks) - for i := 0; i < totalCountBlocks; i++ { + for i := range totalCountBlocks { events <- &fab.BlockEvent{Block: &common.Block{ Header: &common.BlockHeader{ Number: uint64(i), diff --git a/test/unit/chrobot_test.go b/test/unit/chrobot_test.go index b24bedb..3075918 100644 --- a/test/unit/chrobot_test.go +++ b/test/unit/chrobot_test.go @@ -274,7 +274,7 @@ func TestWorkWithErrors(t *testing.T) { //nolint:unparam func createSrcData(dst, src string, startBlock, countBlocks, countTxOrSwaps, emptyBlockEveryN int) []*collectordto.BlockData { var res []*collectordto.BlockData - for i := 0; i < countBlocks; i++ { + for i := range countBlocks { d := &collectordto.BlockData{ BlockNum: uint64(startBlock + i), Size: 0, @@ -283,13 +283,13 @@ func createSrcData(dst, src string, startBlock, countBlocks, countTxOrSwaps, emp continue } if dst == src { - for j := 0; j < countTxOrSwaps; j++ { + for j := range countTxOrSwaps { tx := make([]byte, 4) binary.LittleEndian.PutUint32(tx, uint32(i*countTxOrSwaps+j)) d.Txs = append(d.Txs, tx) } } else { - for j := 0; j < countTxOrSwaps; j++ { + for range countTxOrSwaps { d.Swaps = append(d.Swaps, &proto.Swap{ Owner: nil, Token: "zxcv", diff --git a/test/unit/dto_models_test.go b/test/unit/dto_models_test.go index 3cf7040..f74f77b 100644 --- a/test/unit/dto_models_test.go +++ b/test/unit/dto_models_test.go @@ -50,7 +50,7 @@ func BenchmarkProtoMarshalVsSize(b *testing.B) { func generateBatches() []*proto.Batch { var res []*proto.Batch - for i := 0; i < 1000; i++ { + for range 1000 { b := &proto.Batch{ TxIDs: generateTxses(), Swaps: generateSwaps(), @@ -67,7 +67,7 @@ func generateBatches() []*proto.Batch { func generateTxses() [][]byte { var res [][]byte count := rnd.Intn(100) - for i := 0; i < count; i++ { + for range count { res = append(res, generateBytes()) } return res @@ -76,7 +76,7 @@ func generateTxses() [][]byte { func generateSwaps() []*proto.Swap { var res []*proto.Swap count := rnd.Intn(100) - for i := 0; i < count; i++ { + for range count { s := &proto.Swap{ Id: generateBytes(), Creator: generateBytes(), @@ -96,7 +96,7 @@ func generateSwaps() []*proto.Swap { func generateMultiSwaps() []*proto.MultiSwap { var res []*proto.MultiSwap count := rnd.Intn(100) - for i := 0; i < count; i++ { + for range count { s := &proto.MultiSwap{ Id: generateBytes(), Creator: generateBytes(), @@ -116,7 +116,7 @@ func generateMultiSwaps() []*proto.MultiSwap { func generateSwapKeys() []*proto.SwapKey { var res []*proto.SwapKey count := rnd.Intn(100) - for i := 0; i < count; i++ { + for range count { s := &proto.SwapKey{ Id: generateBytes(), Key: generateString(), @@ -129,7 +129,7 @@ func generateSwapKeys() []*proto.SwapKey { func generateBytes() []byte { var res []byte count := rnd.Intn(100) - for i := 0; i < count; i++ { + for range count { res = append(res, 0) } return res @@ -142,7 +142,7 @@ func generateString() string { func generateAssets() []*proto.Asset { var res []*proto.Asset count := rnd.Intn(100) - for i := 0; i < count; i++ { + for range count { s := &proto.Asset{ Group: generateString(), Amount: generateBytes(), diff --git a/test/unit/loader_test.go b/test/unit/loader_test.go index 42e5da7..bc92914 100644 --- a/test/unit/loader_test.go +++ b/test/unit/loader_test.go @@ -41,7 +41,7 @@ func NoTestPutPreimages(t *testing.T) { amountEmit = 1 ) totalB := oldFiatB - for i := 0; i < countEmits; i++ { + for i := range countEmits { _, err = ntesting.EmitFiat(ctx, fiatOwner, fiatOwner, amountEmit, ciData.HlfFiatChannel, ciData.HlfFiatChannel) if err != nil { l.Infof("emit error: %s", err) diff --git a/test/unit/stub_stor_test.go b/test/unit/stub_stor_test.go index e4e21a3..1c053b6 100644 --- a/test/unit/stub_stor_test.go +++ b/test/unit/stub_stor_test.go @@ -3,6 +3,7 @@ package unit import ( "context" "fmt" + "maps" "sync" "github.com/anoideaopen/common-component/testshlp" @@ -58,9 +59,7 @@ func cloneChCheckPoints(cp *stordto.ChCheckPoint) *stordto.ChCheckPoint { MinExecBlockNum: cp.MinExecBlockNum, } - for k, v := range cp.SrcCollectFromBlockNums { - res.SrcCollectFromBlockNums[k] = v - } + maps.Copy(res.SrcCollectFromBlockNums, cp.SrcCollectFromBlockNums) return res }