golang 的 rabbitmq 消费项目
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

26 lines
475 B

  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(max int) int {
  11. rand.Seed(time.Now().UnixNano()) // seed后随机数可变
  12. return rand.Intn(max) // 0-100的随机数
  13. }
  14. func RandIntRand(min, max int) int {
  15. if min >= max || min == 0 || max == 0 {
  16. if max == 0 {
  17. max = min
  18. }
  19. return max
  20. }
  21. return rand.Intn(max-min) + min
  22. }