I would like to generate a random 17 digits number and parse it to string by golang, here is my code:
const msgMaxValue = 100000000000000000
s := fmt.Sprintf("%17v", rand.New(rand.NewSource(time.Now().UnixNano())).Int63n(msgMaxValue))
log.Info("s:", s)
msgId, err := strconv.Atoi(s)
the error is: invalid syntax, I found there is a space in random value but don't know why, how should I fix it, thank u
Aucun commentaire:
Enregistrer un commentaire