Skip to content

Commit b36f383

Browse files
authored
use math/rand/v2 (fatedier#4020)
1 parent c08be0f commit b36f383

File tree

5 files changed

+16
-25
lines changed

5 files changed

+16
-25
lines changed

.github/workflows/golangci-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
uses: golangci/golangci-lint-action@v4
2424
with:
2525
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
26-
version: v1.56
26+
version: v1.57
2727

2828
# Optional: golangci-lint command line arguments.
2929
# args: --issues-exit-code=0

.golangci.yml

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
service:
2-
golangci-lint-version: 1.56.x # use the fixed version to not introduce new linters unexpectedly
2+
golangci-lint-version: 1.57.x # use the fixed version to not introduce new linters unexpectedly
33

44
run:
55
concurrency: 4
@@ -8,23 +8,6 @@ run:
88
build-tags:
99
- integ
1010
- integfuzz
11-
# which dirs to skip: they won't be analyzed;
12-
# can use regexp here: generated.*, regexp is applied on full path;
13-
# default value is empty list, but next dirs are always skipped independently
14-
# from this option's value:
15-
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
16-
skip-dirs:
17-
- genfiles$
18-
- vendor$
19-
- bin$
20-
21-
# which files to skip: they will be analyzed, but issues from them
22-
# won't be reported. Default value is empty list, but there is
23-
# no need to include all autogenerated files, we confidently recognize
24-
# autogenerated files. If it's not please let us know.
25-
skip-files:
26-
- ".*\\.pb\\.go"
27-
- ".*\\.gen\\.go"
2811

2912
linters:
3013
disable-all: true
@@ -136,6 +119,14 @@ issues:
136119
- unparam
137120
text: "is always false"
138121

122+
exclude-dirs:
123+
- genfiles$
124+
- vendor$
125+
- bin$
126+
exclude-files:
127+
- ".*\\.pb\\.go"
128+
- ".*\\.gen\\.go"
129+
139130
# Independently from option `exclude` we use default exclude patterns,
140131
# it can be disabled by this option. To list all
141132
# excluded by default patterns execute `golangci-lint run --help`.

pkg/nathole/nathole.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ package nathole
1717
import (
1818
"context"
1919
"fmt"
20-
"math/rand"
20+
"math/rand/v2"
2121
"net"
2222
"slices"
2323
"strconv"
@@ -341,7 +341,7 @@ func sendSidMessage(
341341
TransactionID: transactionID,
342342
Sid: sid,
343343
Response: false,
344-
Nonce: strings.Repeat("0", rand.Intn(20)),
344+
Nonce: strings.Repeat("0", rand.IntN(20)),
345345
}
346346
buf, err := EncodeMessage(m, key)
347347
if err != nil {
@@ -398,7 +398,7 @@ func sendSidMessageToRandomPorts(
398398
used := sets.New[int]()
399399
getUnusedPort := func() int {
400400
for i := 0; i < 10; i++ {
401-
port := rand.Intn(65535-1024) + 1024
401+
port := rand.IntN(65535-1024) + 1024
402402
if !used.Has(port) {
403403
used.Insert(port)
404404
return port

pkg/util/util/util.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"crypto/subtle"
2121
"encoding/hex"
2222
"fmt"
23-
mathrand "math/rand"
23+
mathrand "math/rand/v2"
2424
"net"
2525
"strconv"
2626
"strings"
@@ -124,7 +124,7 @@ func RandomSleep(duration time.Duration, minRatio, maxRatio float64) time.Durati
124124
if max <= min {
125125
n = min
126126
} else {
127-
n = mathrand.Int63n(max-min) + min
127+
n = mathrand.Int64N(max-min) + min
128128
}
129129
d := duration * time.Duration(n) / time.Duration(1000)
130130
time.Sleep(d)

pkg/util/wait/backoff.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
package wait
1616

1717
import (
18-
"math/rand"
18+
"math/rand/v2"
1919
"time"
2020

2121
"github.com/fatedier/frp/pkg/util/util"

0 commit comments

Comments
 (0)