For a hands on exercise, I was given the following instructions:
Create a map with a key of TYPE string which is a person’s “last_first” name, and a value of TYPE []string which stores their favorite things. Store three records in your map. Print out all of the values, along with their index position in the slice. bond_james, Shaken, not stirred, Martinis, Women moneypenny_miss, James Bond, Literature, Computer Science no_dr, Being evil, Ice cream, Sunsets
I have trouble understanding some error messages, but others I am learning to figure out. I don’t know what that particular error message means: unexpected Println at end of statement
This is maybe what you want to do. https://play.golang.org/p/UopgdBH15pJ
The map value is a []string. So you need to either create a list in place or create it as a separate variable and then assign it.
Also this:
Go already allows the elision of the type of a composite literal under certain circumstances. This proposal extends that permission to all occasions when the literal type can be derived.
The type cannot be derived in case of a := {1, 2, 3}, since it can possibly be int/uint of some length. I guess this is why it’s not allowed to omit type in slice literal.