The heappermutations package provides a Golang implementation of B. R. Heap's algorithm to generate all possible permutations of typed-datasets.
Based on https://en.wikipedia.org/wiki/Heap's_algorithm
func Permute[T any]([]T) [][]T
Permute returns all permutations of a typed slice.
import ( "github.com/dbyio/heappermutations" )
sInts := []int{1, 2, 3}
pInts := heappermutations.Permute(sInts) // [[1 2 3] [2 1 3] [3 1 2] [1 3 2] [2 3 1] [3 2 1]]
sStrings := []string{"a", "b", "c"}
pStrings := heappermutations.Permute(sStrings) // [[a b c] [b a c] [c a b] [a c b] [b c a] [c b a]]