Once you have your map constructed, you can access a value of the map by providing the key. The syntax is:
value := myMap[myKey]
The key’s type can be any type that can be evaluated by a comparison operator ( >=
, ==
, <=
, etc…). For your example it looks like you are using strings for keys.
Here’s an example:
m := map[string]interface{}{
"from": 0,
"key": nil,
"price": "Desc",
"title": "task",
}
// Get the value of price
price := m["price"]
fmt.Println(price)
// Get the title
title := m["title"]
fmt.Println(title)
// Loop through all of the map's key-value pairs
for key, value := range m {
fmt.Println(key, ":", value)
}
solved How to Decode map golang [closed]