package main
import "fmt"
func main() {
var products = make(map[string]map[string]interface{})
products["product1"] = make(map[string]interface{})
products["product1"]["id"] = "p01"
products["product1"]["name"] = "name 1"
products["product1"]["price"] = 5.6
products["product1"]["status"] = true
products["product2"] = make(map[string]interface{})
products["product2"]["id"] = "p02"
products["product2"]["name"] = "name 2"
products["product2"]["price"] = 7.8
products["product2"]["status"] = false
fmt.Println(products)
fmt.Println("Product List")
for key, product := range products {
fmt.Println(key, ":")
for key, value := range product {
fmt.Println("\t", key, ":", value)
}
}
}
map[product1:map[id:p01 name:name 1 price:5.6 status:true] product2:map[id:p02 name:name 2 price:7.8 status:false]]
Product List
product2 :
id : p02
name : name 2
price : 7.8
status : false
product1 :
id : p01
name : name 1
price : 5.6
status : true