Junior — Middle
Which module in the standard library helps quickly add lines to the end of an existing string?
sobes.tech AI
Answer from AI
In Go, the strings.Builder type from the strings package is used for efficient appending of strings to the end of an existing string. It allows accumulating strings without creating new intermediate objects, which is much faster for multiple concatenations.
Example usage:
import (
"fmt"
"strings"
)
func main() {
var builder strings.Builder
builder.WriteString("Hello")
builder.WriteString(", world!")
result := builder.String()
fmt.Println(result) // Outputs: Hello, world!
}