Richard Bucker

GOLANG concat two arrays of strings

Posted at — Jun 25, 2013

You have two arrays of strings, ‘a’ and ‘b’… and you want to concatenate them. Easy enough see here.// assign the valuesa := strings.Split(“a,b,c”, “,")b := strings.Split(“c,d,f”, “,")This will result in:a = [“a”, “b”, “c”]b = [“c”, “d”, “f”]Now to concatenate the two arrays:c := append(a, b…)That’s all there is to it. GO will return:c = [“a”, “b”, “c”, “c”, “d”, “f”]Notice that “c” is duplicated because it’s in both arrays. Merging without duplicates is a different task.