Golang / GoLang Basics Interview Questions
What is the Go module system? What do go.mod and go.sum contain?
Modules are Go's dependency management system (stable since Go 1.13). A module is a collection of related packages identified by a module path (typically a repository URL). The module's root contains a go.mod file that records the module path, the minimum Go version, and all required dependencies.
// Initialise a module
// $ go mod init github.com/alice/myapp
// go.mod — human-editable; commit to version control
// ─────────────────────────────────────────────────
// module github.com/alice/myapp
//
// go 1.22
//
// require (
// github.com/gin-gonic/gin v1.9.1
// golang.org/x/sync v0.6.0
// )
// go.sum — machine-managed; commit to version control
// Contains SHA-256 hashes of each downloaded module zip
// Guarantees tamper-proof, reproducible builds
// Key commands:
// go get github.com/pkg@v1.2.3 — add / upgrade dependency
// go mod tidy — remove unused, add missing deps
// go mod download — pre-download all deps
// go list -m all — list entire dependency graph
// Minimum Version Selection (MVS):
// Go ALWAYS picks the minimum version that satisfies all requirements.
// Nothing upgrades silently — builds are reproducible.
// Major version imports (breaking changes need new import path):
// import "github.com/alice/pkg/v2" — v2 has breaking API changes
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
