Skip to content

Commit

Permalink
multi: Use go 1.22 language features.
Browse files Browse the repository at this point in the history
  • Loading branch information
jholdstock committed Aug 14, 2024
1 parent b30b42d commit 568d9b6
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cmd/v3tool/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions database/votechange_test.go
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/decred/vspd

go 1.20
go 1.22

require (
decred.org/dcrwallet/v4 v4.1.2
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand All @@ -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.2.2 h1:lqzMYz6bOfvn2WriPUjNByzeXIlVzURcPmgMczkmTjY=
Expand Down Expand Up @@ -131,6 +135,7 @@ 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=
Expand All @@ -145,6 +150,7 @@ golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5D
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand Down
4 changes: 2 additions & 2 deletions internal/vspd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion internal/webapi/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion rpc/dcrwallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit 568d9b6

Please sign in to comment.