The time to use a Map:
- All keys must be the same type
- All values must be the same type
- Keys are indexed – we can iterate over them
- Use to represent a collection of related properties
- Don’t need to know all the keys at compile time
- Reference Type
The time to use a struct
- Values can be different type
- Keys don’t support indexing
- You need to know all the different fields at compile time
- Use to represent a “thing” with a lot of different properties
- Value Type
Credits: Master the fundamentals and advanced features of the Go Programming Language (Golang) from Stephen Grider