The question may sound very stupid but I really don't understand what's wrong.
I want to create an array of maps like this:
values := make([]map[string]string, 0)
Then I create some map:
row := make(map[string]string)
row["item1"] = "value1"
row["item2"] = "value2"
Then append it to the array:
values = append(values, row)
Printing values now gives:
[map[item1:value1 item2:value2]]
Do the same using some other values:
row["item1"] = "value3"
row["item2"] = "value4"
values = append(values, row)
Now printing values gives:
[map[item1:value3 item2:value4] map[item1:value3 item2:value4]]
So the first array item = the second one. What can cause this?
Full code:
package main
import "fmt"
func main() {
values := make([]map[string]string, 0)
row := make(map[string]string)
row["item1"] = "value1"
row["item2"] = "value2"
values = append(values, row)
fmt.Println(values)
row["item1"] = "value3"
row["item2"] = "value4"
values = append(values, row)
fmt.Println(values)
}