First, there is no such requirement in the OP's original post and there is
no mention whether the output is going to be used for another processing
that requires character escaping. The correctness of a solution is judged
against its requirements.
Second, judging from the OP's question, it appe
On Fri, Aug 7, 2020 at 7:46 PM Henry wrote:
> Or you can do it manually:
>
> func print(array []string) string {
> var buffer strings.Builder
> buffer.WriteString("[")
> for index, item := range array {
> if index != 0 {
> buffer.WriteString(", ")
> }
> buffer.WriteString("\"" + item + "\"")
> }
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 wrote:
> Hello Michele
>
> This won't print in the array