golang 的 rabbitmq 消费项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

random.go 489 B

1 year ago
6 months ago
1 year ago
6 months ago
1 year ago
12345678910111213141516171819202122232425262728293031
  1. package utils
  2. import (
  3. "math/rand"
  4. "time"
  5. )
  6. func RandFloats(min, max float64) float64 {
  7. rand.Seed(time.Now().UnixNano())
  8. return min + rand.Float64()*(max-min)
  9. }
  10. func RandInt(min, max int) int {
  11. if min >= max || min == 0 || max == 0 {
  12. if max == 0 {
  13. max = min
  14. }
  15. return max
  16. }
  17. return rand.Intn(max-min) + min
  18. }
  19. func RandIntRand(min, max int) int {
  20. if min >= max || min == 0 || max == 0 {
  21. if max == 0 {
  22. max = min
  23. }
  24. return max
  25. }
  26. return rand.Intn(max-min) + min
  27. }