golang convert "type []string" to string


I’m sure this is a simple question, but I keep bumping into this. I see others are as well.

I see some people create a for loop and run through the slice as to create a string, is there an easier way to convert a []string to a string?

Will sprintf do it?


You can use strings.Join(arr []string, separator string) string, as in pretty much any other language I know


Answered By – Tom Regner

Answer Checked By – David Marino (GoLangFix Volunteer)

Leave a Reply

Your email address will not be published.