Skip to content

Commit dbcd8d3

Browse files
committed
update
1 parent 9d307b2 commit dbcd8d3

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ require (
77
github.com/admpub/fsnotify v1.7.0
88
github.com/admpub/pp v0.0.7
99
github.com/francoispqt/gojay v1.2.13
10-
github.com/goccy/go-json v0.10.3
10+
github.com/goccy/go-json v0.10.4
1111
github.com/hashicorp/go-version v1.7.0
1212
github.com/json-iterator/go v1.1.12
1313
github.com/stretchr/testify v1.9.0
14-
golang.org/x/crypto v0.27.0
15-
golang.org/x/text v0.18.0
14+
golang.org/x/crypto v0.31.0
15+
golang.org/x/text v0.21.0
1616
)
1717

1818
require (
@@ -22,6 +22,6 @@ require (
2222
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
2323
github.com/modern-go/reflect2 v1.0.2 // indirect
2424
github.com/pmezard/go-difflib v1.0.0 // indirect
25-
golang.org/x/sys v0.25.0 // indirect
25+
golang.org/x/sys v0.28.0 // indirect
2626
gopkg.in/yaml.v3 v3.0.1 // indirect
2727
)

string.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -263,19 +263,23 @@ func RandomCreateBytes(n int, alphabets ...byte) []byte {
263263
rd = NewRand()
264264
randby = true
265265
}
266-
for i, b := range bytes {
267-
if len(alphabets) == 0 {
266+
if len(alphabets) == 0 {
267+
size := len(alphanum)
268+
for i, b := range bytes {
268269
if randby {
269-
bytes[i] = alphanum[rd.Intn(len(alphanum))]
270+
bytes[i] = alphanum[rd.Intn(size)]
270271
} else {
271-
bytes[i] = alphanum[b%byte(len(alphanum))]
272+
bytes[i] = alphanum[b%byte(size)]
272273
}
274+
}
275+
return bytes
276+
}
277+
size := len(alphabets)
278+
for i, b := range bytes {
279+
if randby {
280+
bytes[i] = alphabets[rd.Intn(size)]
273281
} else {
274-
if randby {
275-
bytes[i] = alphabets[rd.Intn(len(alphabets))]
276-
} else {
277-
bytes[i] = alphabets[b%byte(len(alphabets))]
278-
}
282+
bytes[i] = alphabets[b%byte(size)]
279283
}
280284
}
281285
return bytes

0 commit comments

Comments
 (0)