Spiderman quotes

Report a typo

Every day you've got a quote from the Spiderman movie, but you've mentioned that you forget the one that was yesterday. To not forget it again, let's write it to a file!

You've already got code that reads a quote from the standard input, so your task is to write the quote to a file to keep it safe!

Write a program
package main

import (
"bufio"
"log"
"os"
)

func main() {
quote := readQuote() // today's quote
file, err := os.Create("quote.txt")
if err != nil {
log.Fatal(err)
}

// TODO: write the quote to a file

}

func readQuote() string {
scanner := bufio.NewScanner(os.Stdin)
scanner.Split(bufio.ScanLines)
_ = scanner.Scan()
return scanner.Text()
}

___

Create a free account to access the full topic