0
0
Goprogramming~10 mins

main package and main function in Go - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare the main package.

Go
package [1]
Drag options to blanks, or click blank then click option'
Afmt
Bhttp
Cos
Dmain
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using other package names like 'fmt' or 'os' instead of 'main'.
Forgetting to write 'package' keyword.
2fill in blank
medium

Complete the code to declare the main function.

Go
func [1]() {
    // program starts here
}
Drag options to blanks, or click blank then click option'
Amain
Bstart
Cinit
Drun
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Naming the function something other than 'main'.
Forgetting the parentheses after the function name.
3fill in blank
hard

Fix the error in the code to make it a valid Go program with main package and main function.

Go
package main

func [1]() {
    println("Hello, Go!")
}
Drag options to blanks, or click blank then click option'
Amain
Bhello
Cstart
DMain
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using uppercase 'Main' instead of 'main'.
Using other function names like 'start' or 'hello'.
4fill in blank
hard

Fill both blanks to create a valid Go program that prints "Welcome!".

Go
package [1]

func [2]() {
    println("Welcome!")
}
Drag options to blanks, or click blank then click option'
Amain
Bfmt
Dstart
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using different names for package and function.
Using 'fmt' as package name which is a library, not the main package.
5fill in blank
hard

Fill all three blanks to create a Go program that prints "Go is fun!" using the main package and main function.

Go
package [1]

func [2]() {
    [3]("Go is fun!")
}
Drag options to blanks, or click blank then click option'
Amain
Bprintln
Dprint
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using 'print' instead of 'println' which is the correct built-in function.
Using wrong package or function names.