Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormhsanaei <ho3ein.sanaei@gmail.com>2025-09-20 10:35:50 +0300
committermhsanaei <ho3ein.sanaei@gmail.com>2025-09-20 10:35:50 +0300
commit6ced549deaecb42b9bb93ea9efcb4c1bbaabe8a4 (patch)
tree28d8d82530476cf607e4d05ca189ae05868711e6 /util/random
parentf60682a6b7cb749fee403c84e2587c3ad7e7ced0 (diff)
docs: add comments for all functions
Diffstat (limited to 'util/random')
-rw-r--r--util/random/random.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/util/random/random.go b/util/random/random.go
index 67ee0691..9610e26c 100644
--- a/util/random/random.go
+++ b/util/random/random.go
@@ -1,3 +1,4 @@
+// Package random provides utilities for generating random strings and numbers.
package random
import (
@@ -13,6 +14,8 @@ var (
allSeq [62]rune
)
+// init initializes the character sequences used for random string generation.
+// It sets up arrays for numbers, lowercase letters, uppercase letters, and combinations.
func init() {
for i := 0; i < 10; i++ {
numSeq[i] = rune('0' + i)
@@ -33,6 +36,7 @@ func init() {
copy(allSeq[len(numSeq)+len(lowerSeq):], upperSeq[:])
}
+// Seq generates a random string of length n containing alphanumeric characters (numbers, lowercase and uppercase letters).
func Seq(n int) string {
runes := make([]rune, n)
for i := 0; i < n; i++ {
@@ -41,6 +45,7 @@ func Seq(n int) string {
return string(runes)
}
+// Num generates a random integer between 0 and n-1.
func Num(n int) int {
return rand.Intn(n)
}