From e413b279988e6b86559da2002948ba16b383a97f Mon Sep 17 00:00:00 2001
From: dtapps
Date: Wed, 20 Dec 2023 14:58:57 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20`Range`=20=20=E6=96=B9?=
=?UTF-8?q?=E6=B3=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
gorandom.go | 16 ++++++++++++++++
version.go | 2 +-
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/gorandom.go b/gorandom.go
index 34281cc..d20176f 100644
--- a/gorandom.go
+++ b/gorandom.go
@@ -48,3 +48,19 @@ func Numeric[T int | int64](n T) string {
func Ascii[T int | int64](n T) string {
return random(n, ascii)
}
+
+func Range(min int64, max int64) int64 {
+
+ var number int64
+ for {
+ // 生成在范围 [min, max) 内的随机数
+ number = int64(rand.Intn(int(max)-int(min)) + int(min))
+
+ // 检查随机数是否大于 min 且小于 max
+ if number > min && number < max {
+ break
+ }
+ }
+
+ return number
+}
diff --git a/version.go b/version.go
index 2ea50d0..c8bf7c3 100644
--- a/version.go
+++ b/version.go
@@ -1,3 +1,3 @@
package gorandom
-const Version = "1.0.1"
+const Version = "1.0.2"