The String() method

Report a typo

Patrick ⭐ has created a very simple Go program that takes 2 of his most famous phrases as a string input and then concatenates them by using the strings.Builder type. Unfortunately, he forgot to print out the concatenated string!

Please help Patrick write the missing method call required to print out the concatenated string.

This problem uses the bufio and os packages to read a whitespace-separated string from the input. To solve this task, you don't need to know how the bufio/os packages work; the only objective is to write the missing method call within the fmt.Println() statement.

Sample Input 1:

Is mayonnaise an instrument? 🎺 
I can't see my forehead! 😳

Sample Output 1:

Is mayonnaise an instrument? 🎺 I can't see my forehead! 😳
Write a program in Go
package main

import (
"bufio"
"fmt"
"os"
"strings"
)

func main() {
var builder strings.Builder

// The 'scanner' lines below allow us to read a string separated by whitespaces do not delete them!
scanner := bufio.NewScanner(os.Stdin)
scanner.Scan()
str1 := scanner.Text()
scanner.Scan()
str2 := scanner.Text()

builder.WriteString(str1)
builder.WriteString(str2)

// What is the missing method call required to print the concatenated string?
fmt.Println(?)
}
___

Create a free account to access the full topic