I notice that when iterating across keys and values in a map, they keys and values all share the same memory address. You can see that here:
package main
import "fmt"
func main() {
myMap := map[string]string{
"hello": "world",
"how": "are",
"you": "today?",
}
for key, value := range myMap {
fmt.Printf("Key: %p %v\n", &key, key)
fmt.Printf("Value: %p %v\n", &value, value)
fmt.Println("---")
}
}
... which outputs ...
Key: 0xc00009e210 hello
Value: 0xc00009e220 world
---
Key: 0xc00009e210 how
Value: 0xc00009e220 are
---
Key: 0xc00009e210 you
Value: 0xc00009e220 today?
---
Why is that?