string - Append key data from the GO MAP -
i have map in go of type :
var userinputmap = make(map[string]string)
the values in :
userinputmap["key1"] = value1 userinputmap["key2"] = value2 userinputmap["key3"] = value3
now, how can generate string contains al above keys in comma seprated format?
output:= "key1,key2,key3"
thanks lot.
iterate in loop , append key string:
package main import "fmt" func main() { var userinputmap = make(map[string]string) userinputmap["key1"] = "value1" userinputmap["key2"] = "value2" userinputmap["key3"] = "value3" output :="" key,_ := range userinputmap { output +=(key+",") } output = output[:len(output)-1] fmt.println(output) }
Comments
Post a Comment