gistlib
In Go, you can join two strings using the plus (+) operator or the strings.Join() function.
strings.Join()
Using the plus operator:
main.gostr1 := "Hello" str2 := "world" result := str1 + " " + str2 // Hello world 75 chars4 lines
str1 := "Hello" str2 := "world" result := str1 + " " + str2 // Hello world
Using the strings.Join() function:
main.gostr1 := "Hello" str2 := "world" result := []string{str1, str2} joinedResult := strings.Join(result, " ") // Hello world 120 chars5 lines
str1 := "Hello" str2 := "world" result := []string{str1, str2} joinedResult := strings.Join(result, " ") // Hello world
gistlibby LogSnag