It seems like you are using this as a slice of characters rather than slice of strings.  A better type for that would be []rune 

Also, this sort of routine is easy to extract into a function and unit testing -- do you mind writing a test for it?