In practice, using strings.Builder
to concat strings is 1000 times faster than +
and fmt.Sprintf()
and uses 1000 times less memory.
func fastStringConcat(strs ...string) string {
var builder strings.Builder
for _, str := range strs {
builder.WriteString(str)
}
return builder.String()
}