0
0
Goprogramming~10 mins

Module initialization 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 module path in the go.mod file.

Go
module [1]
Drag options to blanks, or click blank then click option'
Agithub.com/user/project
Bpackage main
Cimport fmt
Dfunc main()
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'package main' instead of the module path.
Writing 'import fmt' in the module declaration.
Putting function code in go.mod file.
2fill in blank
medium

Complete the code to initialize a new Go module using the command line.

Go
go [1] github.com/user/project
Drag options to blanks, or click blank then click option'
Abuild
Brun
Cmod init
Dget
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'go build' instead of 'go mod init'.
Using 'go get' which is for fetching packages.
Typing 'go run' which runs Go programs.
3fill in blank
hard

Fix the error in the go.mod file by completing the missing keyword.

Go
[1] github.com/user/project

go 1.20
Drag options to blanks, or click blank then click option'
Apackage
Bmodule
Cimport
Dfunc
Attempts:
3 left
💡 Hint
Common Mistakes
Writing 'package' instead of 'module' in go.mod.
Using 'import' or 'func' which are Go code keywords, not module keywords.
4fill in blank
hard

Fill both blanks to complete the go.mod file with module path and Go version.

Go
[1] github.com/example/app

go [2]
Drag options to blanks, or click blank then click option'
Amodule
B1.20
C1.18
Dpackage
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'package' instead of 'module'.
Putting an invalid Go version like 'package' or 'module' in the version line.
5fill in blank
hard

Fill all three blanks to create a minimal go.mod file with module path, Go version, and a require statement.

Go
[1] github.com/my/module

go [2]

require [3] v1.2.3
Drag options to blanks, or click blank then click option'
Amodule
B1.20
Cgithub.com/some/dependency
Dpackage
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'package' instead of 'module' for the first blank.
Putting an invalid Go version in the second blank.
Leaving the require dependency blank or using an invalid path.