Hello, I do not understand why it does not work, I have two maps with the same keys but different values, I need to combine the values of the two maps in an array of structures with matching keys
var mapValues1= map[int64]*typestruct1{1: &typestruct1{"value1", "value2"}, 2: &typestruct1{"value3", "value4"}, 3: &typestruct1{"value5", "value6"}}
var mapValues2= map[int64]*typestruct2{1: &typestruct2{"value7", "value8"} 2: &typestruct2{"value9", "value10"} ,3: &typestruct2{"value11", "value12"}}
type mergeStruct struct {
mgstruct1 *typestruct1
mgstruct2 *typestruct2
}
I need to get an array of structures of combined values from the map with the same keys
func mergeFunc() []*mergeStruct{
mgs:=[]*mergeStruct{}
for kv, v := range typestruct1 {
val := lookUpValue(kv)
mgs = append(mgs, &mergeStruct{v, val})
}
return mgs
}
func lookUpValue(k int64, mv map[int64]*typestruct2) *typeStruct2 {
_, ok := mv[k]
if ok {
n := mv[k]
return n
} else {
return nil
}
}
But it doesn’t work that way, the values are not matched and everything is jumbled, please tell me some other way