Updating the Krusty Krab menu

Report a typo

Mr. Krabs wants to add an additional line to the file galley_grub.txt, which contains the menu of the Krusty Krab.

Can you help Mr. Krabs write the required code to append one additional line: "Kelp Shake $2.00" to the file in his Go program?

Take notice that the file galley_grub.txt has already been opened in append-and-write mode and assigned to the file variable.

Below is the code Mr. Krabs has written so far:

Write a program
package main

import (
"fmt"
"log"
"os"
)

func main() {
// DO NOT DELETE! This opens the 'galley_grub.txt' file in read-write|append mode
file, err := os.OpenFile("galley_grub.txt", os.O_RDWR|os.O_APPEND, 0644)
if err != nil {
log.Println(err)
}
defer file.Close()

// write "Kelp Shake $2.00" to the 'file' variable below with the fmt.Fprintln() function
_, err = fmt.Fprintln(?, "?")
if err != nil {
log.Println(err)
}
}
___

Create a free account to access the full topic