Go Standard Library Cookbook
上QQ阅读APP看书,第一时间看更新

How it works...

For the purpose of joining the string slice into a single string, the Join function of the strings package is there. Simply, you need to provide the slice with strings that are needed to be joined. This way you can comfortably join the string slices. The use of the Join function is shown in steps 1 – 5.

Naturally, the joining could be implemented manually by iterating over the slice. This way you can customize the separator by some more complex logic. The steps 6 – 8 just represent how the manual concatenation could be used with more complex decision logic, based on the string that is currently processed.