Skip to content

Commit a5025a1

Browse files
authored
chore: polish random_util (#192)
Signed-off-by: ZhangJian He <[email protected]>
1 parent f6ad895 commit a5025a1

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

go.mod

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ go 1.20
55
require (
66
github.com/libgox/addr v0.2.0
77
github.com/libgox/gocollections v0.0.0-20241024144716-59fe0afe6953
8+
github.com/libgox/unicodex v0.0.1
89
github.com/prometheus/client_golang v1.20.5
910
github.com/stretchr/testify v1.9.0
1011
golang.org/x/exp v0.0.0-20240823005443-9b4947da3948

go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ github.com/libgox/addr v0.2.0 h1:he4Vv7lzcGy/1qNpjJufEWRql0S23Ki/j0XpTDMDu3s=
1616
github.com/libgox/addr v0.2.0/go.mod h1:j0hEfpRqTZy4BsstS9Egsn1U0JmNdj/VkbF2VBmJlFw=
1717
github.com/libgox/gocollections v0.0.0-20241024144716-59fe0afe6953 h1:qnlK5i5xCbMjQLqFa6JfNn3r7mtRMwMtuqJjyhgAYK8=
1818
github.com/libgox/gocollections v0.0.0-20241024144716-59fe0afe6953/go.mod h1:Y4udpR8lStv1f67hVWbMCrcTyTvf98bFFsu/ZXvAvZ0=
19+
github.com/libgox/unicodex v0.0.1 h1:yUuZWMVXC5N9dcYgIc3aO7+2M5jN+XVatrU08Y5fC4k=
20+
github.com/libgox/unicodex v0.0.1/go.mod h1:RaB9wNp/oOS0Ew5+Wml7WePjztZ3njXiNid08KOmgjs=
1921
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
2022
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
2123
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=

opengemini/random_util.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@ package opengemini
1717
import (
1818
"crypto/rand"
1919
"math/big"
20-
)
2120

22-
const letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
21+
"github.com/libgox/unicodex/letter"
22+
)
2323

2424
func RandBytes(n int64) []byte {
2525
if n <= 0 {
2626
return []byte{}
2727
}
2828
b := make([]byte, n)
2929
for i := range b {
30-
index, err := rand.Int(rand.Reader, big.NewInt(int64(len(letters))))
30+
index, err := rand.Int(rand.Reader, big.NewInt(int64(letter.EnglishCount)))
3131
if err != nil {
3232
panic(err)
3333
}
34-
b[i] = letters[index.Int64()]
34+
b[i] = letter.EnglishLetters[index.Int64()]
3535
}
3636
return b
3737
}

0 commit comments

Comments
 (0)