Is there something like Ruby\'s awesome_print in Go?
For example in Ruby you could write:
require \'ap\'
x = {a:1,b:2} // also works for
I came up to use snippet like this:
func printMap(m map[string]string) {
var maxLenKey int
for k, _ := range m {
if len(k) > maxLenKey {
maxLenKey = len(k)
}
}
for k, v := range m {
fmt.Println(k + ": " + strings.Repeat(" ", maxLenKey - len(k)) + v)
}
}
The output will be like this:
short_key: value1
really_long_key: value2
Tell me, if there's some simpler way to do the same alignment.