I want to have a map of integers to slices with different dimensions.
var SIZE_TO_PERM = make(map[int][][]uint32, 3)
var THREE_C_THREE = [...][3]int {
{0, 1, 2},
}
var FOUR_C_THREE = [...][3]int {
{0, 1, 2}, {0, 1, 3}, {0, 3, 2}, {3, 1, 2},
}
var FIVE_C_THREE = [...][3]int {
// ... etc
}
func init() {
SIZE_TO_PERM = map[int][][]uint32 {
3 : THREE_C_THREE,
4 : FOUR_C_THREE,
5 : FIVE_C_THREE,
}
}
But this doesn't work, as Go throws errors:
# command-line-arguments
./test.go:96: cannot use THREE_C_THREE (type [1][5]int) as type [][]uint32 in map value
./test.go:97: cannot use FOUR_C_THREE (type [4][5]int) as type [][]uint32 in map value
./test.go:98: cannot use FIVE_C_THREE (type [20][5]int) as type [][]uint32 in map value
How can I get around this? Perhaps I could somehow have Go map an int to a pointer/reference to a map? Then all the types would be the same, I'd just have to follow the address to get the map there. The problem is I wouldn't know apriori which type I'd find there...
All new to Go, so any tips appreciated.