The Join
method of the strings
module is used to condense strings.
func Join(elems []string, sep string) string
You need to give two arguments as input:
The method returns the merged string.
In this example, we will create a slice of string and merge it with the character ,
(note the space).
See the code below.
package mainimport ("fmt""strings")func main() {s := []string{"Hello", "educative!"}fmt.Println(strings.Join(s, ", "))}