The Krusty Krab menu

Report a typo

Mr. Krabs wants to open and read the whole contents of a small text file called galley_grub.txt, which contains the menu of the Krusty Krab.

Can you help Mr. Krabs write the required code to open and read the file in his Go program?

Write a program
package main

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

func main() {
file, err := ? // open the file here with the os.ReadFile() function
if err != nil {
log.Fatal(err) // exit if we have an unexpected error
}
// print the contents of the file here as a string
}
___

Create a free account to access the full topic