mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-13 08:56:32 -06:00
Merge pull request #13112 from jen20/acctest-random-int-range
helper/acctest: Add RandIntRange helper function
This commit is contained in:
commit
6d99dc5466
@ -24,6 +24,14 @@ func RandInt() int {
|
||||
return rand.New(rand.NewSource(time.Now().UnixNano())).Int()
|
||||
}
|
||||
|
||||
func RandIntRange(min int, max int) int {
|
||||
reseed()
|
||||
source := rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||
rangeMax := max - min
|
||||
|
||||
return int(source.Int31n(int32(rangeMax)))
|
||||
}
|
||||
|
||||
// RandString generates a random alphanumeric string of the length specified
|
||||
func RandString(strlen int) string {
|
||||
return RandStringFromCharSet(strlen, CharSetAlphaNum)
|
||||
|
Loading…
Reference in New Issue
Block a user