My exporter builds a CSV report by doing out += line + "\n" inside a loop over about 100,000 records. It takes many seconds, and the memory profile shows an enormous total allocation figure even though the final string is only around 5 MB.
I understand that strings are immutable in Go, but I do not see why the cost grows so badly. What is the idiomatic way to build a big string, and does it matter for small cases such as joining three or four pieces?




