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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -