On Fri, Aug 7, 2020 at 7:46 PM Henry <henry.adisuma...@gmail.com> 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 + "\"") > } > buffer.WriteString("]") > return buffer.String() > } > Consider what is emitted if the item contains a double-quote rune. In other words, your solution is naive and only produces unambiguous, correct, output for a subset of cases. -- Kurtis Rader Caretaker of the exceptional canines Junior and Hank -- 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/CABx2%3DD_7Rq0N%2Bxn8Xv%2B_GjseZTS-4Q9%2BP-Dd5KHS9-PawJ9_zw%40mail.gmail.com.