fmt.Sprintf("template with %s %s %s... placeholders", str1, str2 str3, ...)
fmt.Fprintf()
instead ofSprintf()
str1 + str2 + str3 + ...
- using a
strings.Builder
'sWriteString()
on the string pieces, and then return the result from theString()
method
I am writing email service that generates SMTP messages which contains long chunks of Base64 encoded file contents, and involves lots of text concatenation to form headers. On high traffics, I try to avoid creating copies of Base64 file contents.
I wanna know if strings.Builder
clearly wins over the other two approaches in terms of the efficiency of memory use and time taken.