xxxxxxxxxx
m := make(map[string]int)
m["numberOne"] = 1
m["numberTwo"] = 2
xxxxxxxxxx
for _, note := range notes {
thisNote := map[string]string{
"Title":note.Title,
"Body":note.Body,
}
content["notes"] = append(content["notes"], thisNote)
}
xxxxxxxxxx
{ "notes":
{
"Title":note.Title,
"Body":note.Body,
},
{
"Title":note.Title,
"Body":note.Body,
},
{
"Title":note.Title,
"Body":note.Body,
},
}
xxxxxxxxxx
package main
import ("fmt")
func main() {
// create a map
students := map[int]string{1: "John", 2: "Lily"}
fmt.Println("Initial Map: ", students)
// add element with key 3
students[3] = "Robin"
// add element with key 5
students[5] = "Julie"
fmt.Println("Updated Map: ", students)
}