Concatenate strings in Golang
Concatenate string literals (string enclosed in double quotes).
To concatenate strings simply, use + operator.
However, if strings are concatenated by + operator, new string object is generated.
If you use bytes.Buffer, string is stored in buffer.
As a result, bytes.buffer prevents unnecessary string object from generating.
concatenate_string_literal.go
package main

import (
	"bytes"
	"fmt"
)

func main() {
	// Concatenate string literal simply
	fmt.Println("Panda " + "is " + "cute.")
	// However, string object is generated for every + is used

	// If bytes.Buffer is used, new object is not generated
	// when string is concatenated
	// Here, bytes.Buffer is a variable-sized buffer of bytes.
	var buffer bytes.Buffer
	buffer.WriteString("P")
	buffer.WriteString("a")
	buffer.WriteString("n")
	buffer.WriteString("d")
	buffer.WriteString("a")
	fmt.Println(buffer.String())

	buffer.WriteString(" ")
	buffer.WriteString("i")
	buffer.WriteString("s")
	buffer.WriteString(" ")
	buffer.WriteString("c")
	buffer.WriteString("u")
	buffer.WriteString("t")
	buffer.WriteString("e")
	buffer.WriteString(".")
	fmt.Println(buffer.String())
}

      
Result
$ go run concatenate_string_literal.go
Panda is cute.
Panda
Panda is cute.