Python like string formatting for golang.
Golang already has great features for string formatting (entire fmt package) I missed named parameters for string formatting. Intention of this library is to mimic subset of features that python's format function offers.
Simple way of formatting string is using something like this:
// outputs "some value"
gstring.Printm("{key}", map[string]interface{}{"key": "some value"})
If bracked is needed in string it can be created by escaping (two brackets). Also, single key can appear multiple times in format string:
// outpits "Bracket {, }, key value, key value, key value"
gstring.Printm("Bracket {{, }}, {key}, {key}, {key}", map[string]interaface{}{"key", "key value"})
All standard formatting options from fmt work. To specify them, add colon after key name and specify fmt package compatible formatting optinos. For example:
// outpus "3.14"
gstring.Printm("{pi:%.2f}", map[string]interface{}{"pi": math.Pi})
Run go get github.com/delicb/gstring
from command line.