I am new to go and trying to implement python like nested structure as below, I am not able to define the empty dict/map in golang that can have list of specific struct/classobj and while iterating through the data I am not able to append items in map/dict ... I will really appreciate any help on this ... Thanks
items = [
("item1", someObj1),
("item2", someObj2),
("item3", someObj3),
("item3", someObj5),
("item1", someObj4),
]
rectors = {}
for item, obj in items:
try:
rectors[item].append(obj)
except KeyError:
rectors[item] = [obj]
print rectors
# OUTPUT: {'item2': [someObj2], 'item3': [someObj3, someObj5], 'item1': [someObj1, someObj4]}