-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Description
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version)?
go version go1.8.3 linux/amd64
What operating system and processor architecture are you using (go env)?
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/lgalvin/go"
GORACE=""
GOROOT="/usr/lib/go"
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build653200321=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
What did you do?
Tried to use Perm to retrieve random values.
package main
import (
"fmt"
"math/rand"
)
func main() {
for _, value := range rand.Perm(3) {
fmt.Println(value)
}
// Unordered output: 1
// 2
// 0
}
always returns:
0
1
2
The values are not randomised.
Run it here: https://play.golang.org/p/gOAw978ZNI
What did you expect to see?
Randomised values.
What did you see instead?
Same order each time:
0
1
2