When using Value types, Use pointers to modify these things in a function
| Value Types | Reference Types |
|---|---|
| int | slices |
| float | maps |
| string | channels |
| boot | pointers |
| structs | functions |
| Maps | Structs |
|---|---|
| All keys must be in the same type | - |
| All values must be the same type | Values can be of different types |
| Keys are indexed (can iterate over it) | Keys don't support indexing |
| Use to represent a collection of related props | Use to represent a "thing" with a lot of different props |
| Don't need to know all the keys at compile time | Need to know all the different fields at compile time |
| Reference Type | Value Type |
The following snippets are the same :
for s := range c {
fmt.Println(s)
}
for {
fmt.Println(<- c)
}