Perm in Go

Posted by GoDoc
Public (Editable by Users)

Perm returns, as a slice of n ints, a pseudo-random permutation of the integers [0,n) from the default Source.

Go
Edit
package main

import (
	"fmt"
	"math/rand"
)

func main() {
	for _, value := range rand.Perm(3) {
		fmt.Println(value)
	}

	// Unordered output: 1
	// 2
	// 0
}