String interpolation on the value of a Map interface

anotherValue := "aValue"
Banana := map[string]map[string]interface{}{
		"amap": map[string]interface{}{
			"aKey": "aValue",
			"anotherKey": fmt.Printf("another Value %s", anotherValue)

I am trying to do a string interpolation with a variable inside a map, for a “value”. Refer value of “anotherKey” from above. If you see I am trying to do fmt.Printf() but that doesnt work. How can I solve this problem of string interpolation/formatting for a “key/value” inside a map?
I tried few different options but nothing seem to work.

Is this what you’re trying to do?

1 Like

Awesome, thank you. I am a noob in golang. Just understood the difference between Printf and Sprintf. The latter returns one string value, convenient to use inside the map. Thanks gain…you saved my day literally.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.