Go生成6位随机数

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
package main

import (
  "math/rand"
	"strconv"
)

func CreateVerifyCode() (verifyCode string) {
	min := 100000
	max := 999999
	verifyCode = strconv.Itoa(rand.Intn(max-min) + min)
	return
}
Licensed under CC BY-NC-SA 4.0
Built with Hugo
Theme Stack designed by Jimmy