diff --git a/.golangci.yml b/.golangci.yml index 0cc0c73d..e16ae12d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -7,13 +7,13 @@ linters: - asciicheck - bidichk - containedctx + - copyloopvar - dupword - durationcheck - errcheck - errchkjson - errorlint - exhaustive - - exportloopref - fatcontext - goconst - godot diff --git a/cmd/v3tool/main.go b/cmd/v3tool/main.go index 2537db6e..2038e6cd 100644 --- a/cmd/v3tool/main.go +++ b/cmd/v3tool/main.go @@ -107,7 +107,7 @@ func run() int { log.Infof(" %s", tkt) } - for i := 0; i < len(tickets.Hashes); i++ { + for i := range len(tickets.Hashes) { // Stop if shutdown requested. if ctx.Err() != nil { return 0 diff --git a/database/encoding_test.go b/database/encoding_test.go index b12f53dd..6aa54e16 100644 --- a/database/encoding_test.go +++ b/database/encoding_test.go @@ -1,4 +1,4 @@ -// Copyright (c) 2022 The Decred developers +// Copyright (c) 2022-2024 The Decred developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. @@ -63,7 +63,6 @@ func TestBytesToStringMap(t *testing.T) { } for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { t.Parallel() result, err := bytesToStringMap(test.input) diff --git a/database/votechange_test.go b/database/votechange_test.go index f63611ce..c9bddaf4 100644 --- a/database/votechange_test.go +++ b/database/votechange_test.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020 The Decred developers +// Copyright (c) 2020-2024 The Decred developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. @@ -39,7 +39,7 @@ func testVoteChangeRecords(t *testing.T) { } // Insert some more records, giving us one greater than the limit. - for i := 0; i < maxVoteChangeRecords; i++ { + for range maxVoteChangeRecords { err = db.SaveVoteChange(hash, record) if err != nil { t.Fatalf("error storing vote change record in database: %v", err) diff --git a/go.mod b/go.mod index a1bb9af7..01f63c01 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/decred/vspd -go 1.20 +go 1.22 require ( decred.org/dcrwallet/v4 v4.1.3 @@ -25,7 +25,7 @@ require ( github.com/jrick/bitset v1.0.0 github.com/jrick/logrotate v1.1.2 github.com/jrick/wsrpc/v2 v2.3.5 - go.etcd.io/bbolt v1.3.9 + go.etcd.io/bbolt v1.3.11 ) require ( diff --git a/go.sum b/go.sum index 65038310..bfd11ade 100644 --- a/go.sum +++ b/go.sum @@ -67,6 +67,7 @@ github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU= github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= +github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= @@ -76,9 +77,12 @@ github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaC github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= +github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= +github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/gorilla/securecookie v1.1.2 h1:YCIWL56dvtr73r6715mJs5ZvhtnY73hBvEF8kXD8ePA= github.com/gorilla/securecookie v1.1.2/go.mod h1:NfCASbcHqRSY+3a8tlWJwsQap2VX5pwzwo4h3eOamfo= github.com/gorilla/sessions v1.3.0 h1:XYlkq7KcpOB2ZhHBPv5WpjMIxrQosiZanfoy1HLZFzg= @@ -131,12 +135,13 @@ github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXl github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= +github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE= github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= -go.etcd.io/bbolt v1.3.9 h1:8x7aARPEXiXbHmtUwAIv7eV2fQFHrLLavdiJ3uzJXoI= -go.etcd.io/bbolt v1.3.9/go.mod h1:zaO32+Ti0PK1ivdPtgMESzuzL2VPoIG1PCQNvOdo/dE= +go.etcd.io/bbolt v1.3.11 h1:yGEzV1wPz2yVCLsD8ZAiGHhHVlczyC9d1rP43/VCRJ0= +go.etcd.io/bbolt v1.3.11/go.mod h1:dksAq7YMXoljX0xu6VF5DMZGbhYYoLUalEiSySYAS4I= golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc= golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys= @@ -145,6 +150,7 @@ golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn5 golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= diff --git a/internal/vspd/config.go b/internal/vspd/config.go index 8dc65e6a..13b26405 100644 --- a/internal/vspd/config.go +++ b/internal/vspd/config.go @@ -379,7 +379,7 @@ func LoadConfig() (*Config, error) { // Load dcrwallet RPC certificate(s). walletCerts := make([][]byte, numCert) - for i := 0; i < numCert; i++ { + for i := range numCert { certs[i] = cleanAndExpandPath(certs[i]) walletCerts[i], err = os.ReadFile(certs[i]) if err != nil { @@ -394,7 +394,7 @@ func LoadConfig() (*Config, error) { } // Add default port for the active network if there is no port specified. - for i := 0; i < numHost; i++ { + for i := range numHost { walletHosts[i] = normalizeAddress(walletHosts[i], cfg.network.WalletRPCServerPort) } diff --git a/internal/webapi/formatting_test.go b/internal/webapi/formatting_test.go index 589c3753..eebc68ef 100644 --- a/internal/webapi/formatting_test.go +++ b/internal/webapi/formatting_test.go @@ -1,3 +1,7 @@ +// Copyright (c) 2023-2024 The Decred developers +// Use of this source code is governed by an ISC +// license that can be found in the LICENSE file. + package webapi import ( @@ -39,7 +43,6 @@ func TestIndentJSON(t *testing.T) { } for testName, test := range tests { - test := test t.Run(testName, func(t *testing.T) { t.Parallel() actual := indentJSONFunc(test.input) diff --git a/internal/webapi/middleware.go b/internal/webapi/middleware.go index 3d61d5c9..42ad9623 100644 --- a/internal/webapi/middleware.go +++ b/internal/webapi/middleware.go @@ -290,7 +290,7 @@ func (w *WebAPI) broadcastTicket(c *gin.Context) { txBroadcast := func() bool { // Wait for 1 second and try again, max 7 attempts. - for i := 0; i < 7; i++ { + for range 7 { time.Sleep(1 * time.Second) err := dcrdClient.SendRawTransaction(request.ParentHex) if err == nil { diff --git a/rpc/dcrwallet.go b/rpc/dcrwallet.go index 728f59b9..45730e1d 100644 --- a/rpc/dcrwallet.go +++ b/rpc/dcrwallet.go @@ -34,7 +34,7 @@ type WalletConnect struct { func SetupWallet(user, pass, addrs []string, cert [][]byte, params *chaincfg.Params, log slog.Logger) WalletConnect { clients := make([]*client, len(addrs)) - for i := 0; i < len(addrs); i++ { + for i := range len(addrs) { clients[i] = setup(user[i], pass[i], addrs[i], cert[i], log) }