🏗️ move make sub-cmd to sub-dir

This commit is contained in:
zhaoyupeng
2025-11-25 15:46:28 +08:00
parent 454e0639a0
commit 62b680dca8
27 changed files with 750 additions and 105 deletions

13
pkg/tool/random/str.go Normal file
View File

@@ -0,0 +1,13 @@
package random
import "math/rand"
const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
func RandomString(length int) string {
b := make([]byte, length)
for i := range b {
b[i] = charset[rand.Intn(len(charset))]
}
return string(b)
}

View File

@@ -0,0 +1,26 @@
package random_test
import (
"testing"
"yizhisec.com/hsv2/forge/pkg/tool/random"
)
func TestRandomString(t *testing.T) {
tests := []struct {
name string // description of this test case
// Named input parameters for target function.
length int
want string
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := random.RandomString(tt.length)
// TODO: update the condition below to compare got with tt.want.
if true {
t.Errorf("RandomString() = %v, want %v", got, tt.want)
}
})
}
}