One option is to use json.Marshal or json.Encoder.Encode fmt.Printf("%q", []string{"Hello", "world", "!") would quote the separate strings and put the square brackets, but doesn't comma separate the items.
On Thu, Aug 6, 2020 at 9:24 AM <ranjan1234bi...@gmail.com> wrote: > Hello Michele > > This won't print in the array format rather it would print it in other way. > stringArray := []string{"Hello", "world", "!"} > fmt.Printf("[%s]", strings.Join(stringArray , ",")) > > Output [Hello,world,!] > > > > On Thursday, October 10, 2019 at 10:41:59 PM UTC+5:30, Michele Caci wrote: >> >> Hello Nalin, >> >> If you use a slice of strings to hold your data, as an alternative you >> could go with >> >> fmt.Printf("[%s]", strings.Join(your_slice_of_strings, ",")) >> >> Cheers! > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/10afc2a5-bbc9-4a21-ab14-112b1cd3e74co%40googlegroups.com > <https://groups.google.com/d/msgid/golang-nuts/10afc2a5-bbc9-4a21-ab14-112b1cd3e74co%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CANKfucbi5_%3DfsD99xvMWqMj1ME6r-vu%3D%2B4r0J_y%2Bu55xSLvfgQ%40mail.gmail.com.