I am working with a map that goes from byte arrays to 2D lists whose separate list elements are unsigned 32 bit integers. i.e. map[[8]byte][][]uint32
Currently, I have logic that checks to see if the 2D list is populated, and if it isn't, I add two empty lists. From there I can begin to actually fill these lists. Like so:
my_map := make(map[[8]byte][][]uint32)
/* Some logic to define x and i */
if len(my_map[x]) == 0 {
/* Create two fresh inner-lists */
}
my_map[x][0] = append(my_map[x][0], uint32(i))
However, that isn't the most elegant, nor efficient seeming solution. I was wondering if GO had a way to automatically populate a map's 2D list values with inner lists upon creation of a new mapping. Alternatively, if there is a better datatype to be using, I am all ears.
Essentially, here is what I want to be able to do:
my_map := make(map[[8]byte][][]uint32)
/* Some logic to define x and i */
my_map[x][0] = append(my_map[x][0], uint32(i))