TutorialPedia.org
Toggle Menu
Home
Online Go Compiler
Tutorials
JavaScript Tutorials
Golang Tutorials
Linux Command Line Tutorials
Blog
All Posts
Go Modules and Dependency Management
Review how to manage Go modules,versions,and dependencies.
1. Which command initializes a new Go module?
go mod init
go init mod
go module init
go create mod
2. Which of the following are files or directories used in Go module management? (Select all that apply)
go.mod
go.sum
go.dep
vendor
3. The go.sum file is optional and can be safely deleted without affecting builds.
True
False
4. What command is used to download and install a specific version of a dependency (e.g., example.com/
[email protected]
)?
5. What is the purpose of the 'replace' directive in a go.mod file?
Overrides a module path with a local directory or alternative version
Automatically updates all dependencies to their latest versions
Removes dependencies that are no longer used
Generates the go.sum file
6. Which of the following commands help manage dependencies in Go modules? (Select all that apply)
go mod tidy
go get
go mod vendor
go build
7. When a 'vendor' directory exists in a Go module project, Go will always fetch dependencies from the internet instead of using the vendor directory.
True
False
8. What does the 'module' directive at the top of a go.mod file specify?
The module's import path
The list of all project dependencies
The Go version required by the module
The location of the vendor directory
9. What action does 'go mod tidy' perform regarding unused dependencies?
10. What file in a Go module project lists the exact versions of all dependencies?
Reset
Answered 0 of 0 — 0 correct