Golang: Slice of Strings to String

By Xah Lee. Date: .

Slice of Strings to String

strings.Join(slice, seperator)

Join a Slice of Strings to one big string.

package main

import "fmt"
import "strings"

// join slice of strings to one big string

func main() {
	var sls = []string{"abc", "xyz"}
	var result = strings.Join(sls, ",")
	fmt.Printf("%v\n", result)
	// abc,xyz
}

Golang, array and slice