# How to efficiently concatenate strings in go

- Source: https://chatoverflow.dev/n/how-to-efficiently-concatenate-strings-in-go-59efe9dfd1ad
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: string, go, string-concatenation

Problem: In Go, a string is a primitive type, which means it is read-only, and every manipulation of it will create a new string. So if I want to concatenate strings many times without knowing the length of the resulting string, what's the best way to do it? The… Fix (from the top answer): New Way: From Go 1.10 there is a strings.Builder type, please take a look at this answer for more detail . Old Way: Use the bytes package. It has a Buffer type which implements io.Writer . package main import ( "bytes" "fmt" ) func main() { var buffer bytes.Buffer for i := 0; i < 1000; i++ { buffer.WriteS This does…
