0
0
Goprogramming~5 mins

Writing first Go program - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the basic structure of a Go program?
A Go program starts with a package main declaration, followed by an import statement for packages, and a func main() function where the program begins execution.
Click to reveal answer
beginner
What does the func main() function do in a Go program?
The func main() function is the entry point of a Go program. It is where the program starts running.
Click to reveal answer
beginner
How do you print text to the console in Go?
You use the fmt.Println() function from the fmt package to print text to the console.
Click to reveal answer
beginner
What package must you import to use <code>fmt.Println()</code>?
You must import the <code>fmt</code> package using <code>import "fmt"</code>.
Click to reveal answer
beginner
Why do Go programs start with package main?
The package main tells Go this is an executable program, not a library. It must have a main function to run.
Click to reveal answer
What keyword starts a Go program's main file?
Abegin program
Bpackage main
Cimport main
Dfunc start
Which function is the entry point of a Go program?
Afunc start()
Bfunc init()
Cfunc main()
Dfunc run()
How do you print "Hello, World!" in Go?
Afmt.Println("Hello, World!")
Bprint("Hello, World!")
Cconsole.log("Hello, World!")
Decho "Hello, World!"
Which package do you import to use fmt.Println()?
Afmt
Bio
Cos
Dlog
What happens if you omit package main in a Go program?
AProgram runs normally
BProgram prints an error automatically
CProgram runs but skips main function
DProgram becomes a library, no executable
Describe the steps to write and run your first Go program that prints "Hello, World!".
Think about the structure and the print statement.
You got /5 concepts.
    Explain why the main function and package main are essential in a Go program.
    Focus on program start and type.
    You got /4 concepts.