All Projects → matryer → m

matryer / m

Licence: MIT license
Get and Set using JavaScript notation

Programming Languages

go
31211 projects - #10 most used programming language

GoDoc

m

Map utilities for Go

Get and Set using JavaScript notation

Before (yeah it scrolls):

// set the city
data.(map[string]interface{})["addresses"].([]interface{})[0].(map[string]interface{})["city"] = "London"
// get the city
city := data.(map[string]interface{})["addresses"].([]interface{})[0].(map[string]interface{})["city"]
  • Panics if any piece is missing or wrong type

After:

m.Set(data, "addresses[0].city", "London")
city := m.Get(data, "addresses[0].city")
  • Returns nil if any piece is missing or wrong type
  • Use GetOK for a second argument bool
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].