On Tue, Feb 25, 2020 at 11:42 AM Anjana Prabhakar
<prabhakar.anj...@gmail.com> wrote:
>
> Hi All,
>
> I am trying to generate a random integer using the below code snippet:
> package ABC
> import (
> *****
> "math/rand"
> )
> func execBlock(
> logger log.Logger,) {
> var validTxs, invalidTxs, unchkdTxs = 0, 0, 0
>
> txIndex := 0
> proxyCb := func(req *xxx, res *yyy) {
> if r, ok := res.Value.(*yyyy); ok {
> txRes := r.DeliverTx
> // code for random integer begin
>   s1 := rand.NewSource(time.Now().UnixNano())
>     r1 := rand.New(s1)
> toCheck := r1.randIntn(100) // getting error for this line
> if toCheck <= 65{
> ***********
> }else {
> *********
> }// end
> }
> }
> }
>
> I get the error as r1.randIntn undefined (type *math/rand.Rand has no field 
> or method randIntn). Please help.

It doesn't have randIntn, it has Intn, so use r1.Intn(100)

>
> Thanks,
> Anjana
>
> --
> You received this message because you are subscribed to the Google Groups 
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/5f0fc1e1-3554-4d2d-b7e4-0fbc196e1b53%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAMV2Rqq04S4DFNLi6iX81%2BQDPsm%2BzqGjaNGcRXvOsA%3D2NDoNoQ%40mail.gmail.com.

Reply via email to