Mapping Values by a Combination of Two Keys
The topic was found during optimization. When the combination of 2 string type keys maps to a value, how do you maintain the mapping from keys to the value? Generally we can come up with 3 approaches listed below, which one is better?
type Result string
// 1d map, you need to concatenate 2 strings
var d1M map[string]Result
// 1d map and use struct as key
type Key struct {
S1, S2 string
}
var d1MS map[Key]Result
// 2d map
var d2M map[string]map[string]Result