Space due to all empty elements in dep_string. When you use the make function, it creates a slice with the specified length and capacity, filled with a bunch of nothing. Then, when you use the append, it sees that the slice has reached its maximum capacity, expands the slice, and then adds your elements after nothing. The solution is to make a slice with the ability to hold all your elements, but with an initial length of zero:
dep_string := make ([]string, 0, len(tests) + len(sfinal))
string.TrimSpace is not needed. You can read more at http://blog.golang.org/slices
Vitruvius
source share