Skip to content

Commit 568d9b6

Browse files
committed
multi: Use go 1.22 language features.
1 parent b30b42d commit 568d9b6

File tree

7 files changed

+14
-8
lines changed

7 files changed

+14
-8
lines changed

cmd/v3tool/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func run() int {
107107
log.Infof(" %s", tkt)
108108
}
109109

110-
for i := 0; i < len(tickets.Hashes); i++ {
110+
for i := range len(tickets.Hashes) {
111111
// Stop if shutdown requested.
112112
if ctx.Err() != nil {
113113
return 0

database/votechange_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2020 The Decred developers
1+
// Copyright (c) 2020-2024 The Decred developers
22
// Use of this source code is governed by an ISC
33
// license that can be found in the LICENSE file.
44

@@ -39,7 +39,7 @@ func testVoteChangeRecords(t *testing.T) {
3939
}
4040

4141
// Insert some more records, giving us one greater than the limit.
42-
for i := 0; i < maxVoteChangeRecords; i++ {
42+
for range maxVoteChangeRecords {
4343
err = db.SaveVoteChange(hash, record)
4444
if err != nil {
4545
t.Fatalf("error storing vote change record in database: %v", err)

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/decred/vspd
22

3-
go 1.20
3+
go 1.22
44

55
require (
66
decred.org/dcrwallet/v4 v4.1.2

go.sum

+6
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm
6767
github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU=
6868
github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
6969
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
70+
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
7071
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
7172
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
7273
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
7677
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
7778
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
7879
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
80+
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
7981
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
82+
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
8083
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
8184
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
85+
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
8286
github.com/gorilla/securecookie v1.1.2 h1:YCIWL56dvtr73r6715mJs5ZvhtnY73hBvEF8kXD8ePA=
8387
github.com/gorilla/securecookie v1.1.2/go.mod h1:NfCASbcHqRSY+3a8tlWJwsQap2VX5pwzwo4h3eOamfo=
8488
github.com/gorilla/sessions v1.2.2 h1:lqzMYz6bOfvn2WriPUjNByzeXIlVzURcPmgMczkmTjY=
@@ -131,6 +135,7 @@ github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXl
131135
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
132136
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
133137
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY=
138+
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
134139
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
135140
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
136141
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
@@ -145,6 +150,7 @@ golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5D
145150
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
146151
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
147152
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
153+
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
148154
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
149155
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
150156
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

internal/vspd/config.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ func LoadConfig() (*Config, error) {
379379

380380
// Load dcrwallet RPC certificate(s).
381381
walletCerts := make([][]byte, numCert)
382-
for i := 0; i < numCert; i++ {
382+
for i := range numCert {
383383
certs[i] = cleanAndExpandPath(certs[i])
384384
walletCerts[i], err = os.ReadFile(certs[i])
385385
if err != nil {
@@ -394,7 +394,7 @@ func LoadConfig() (*Config, error) {
394394
}
395395

396396
// Add default port for the active network if there is no port specified.
397-
for i := 0; i < numHost; i++ {
397+
for i := range numHost {
398398
walletHosts[i] = normalizeAddress(walletHosts[i], cfg.network.WalletRPCServerPort)
399399
}
400400

internal/webapi/middleware.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ func (w *WebAPI) broadcastTicket(c *gin.Context) {
290290

291291
txBroadcast := func() bool {
292292
// Wait for 1 second and try again, max 7 attempts.
293-
for i := 0; i < 7; i++ {
293+
for range 7 {
294294
time.Sleep(1 * time.Second)
295295
err := dcrdClient.SendRawTransaction(request.ParentHex)
296296
if err == nil {

rpc/dcrwallet.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ type WalletConnect struct {
3434
func SetupWallet(user, pass, addrs []string, cert [][]byte, params *chaincfg.Params, log slog.Logger) WalletConnect {
3535
clients := make([]*client, len(addrs))
3636

37-
for i := 0; i < len(addrs); i++ {
37+
for i := range len(addrs) {
3838
clients[i] = setup(user[i], pass[i], addrs[i], cert[i], log)
3939
}
4040

0 commit comments

Comments
 (0)