Modules and tooling
go.mod, versioning, build flags, and what runs in CI.
What does go.sum hold?
All questions with explanations (answers shown)
1. What does
go.sumhold?Answer: Cryptographic checksums of every module version, making builds reproducible and tamper-evident
Commit it. Together with
go.modit is why Go needs no separate lockfile.2. Go picks which version of a shared dependency?
Answer: The oldest that satisfies everyone — Minimal Version Selection
Your build does not change because someone else published a release. Upgrades only happen when you ask for one.
3. What does
CGO_ENABLED=0give you?Answer: A fully static binary with no libc dependency — which is what makes distroless images and cross-compiling work
It is the flag behind both the ~15MB container image and
GOOS=linux GOARCH=arm64 go buildneeding no toolchain.4. You publish a breaking change to your library. What must the module path become?
Answer:
github.com/you/thing/v2The major version lives in the import path from v2 onward, so v1 and v2 can coexist in one build.
5. Which four commands should gate every push?
Answer:
gofmt -l,go vet,go test -race,govulncheckFormatted, vetted, race-free and free of known vulnerabilities.
govulncheckis low-noise because it only reports vulnerabilities in code you actually call.6. Which routers let you keep the standard
func(http.ResponseWriter, *http.Request)handler?Answer:
net/httpand chichi is a thin router over
net/http, so every standard middleware andhttpteststill work. gin, echo and fiber each define their own context and handler type.7. You see
c.JSON(200, gin.H{...})in a handler. What does that tell you?Answer: Every handler is tied to gin — moving away means rewriting them all
gin.Hand*gin.Contextonly exist in gin. Going to gin is easy; coming back means rewriting every handler signature.8. Ordered from most control over the SQL to least, which is right?
Answer: database/sql → sqlx → sqlc → GORM
database/sqlis raw.sqlxscans for you but keeps your SQL.sqlcgenerates typed Go from your SQL. GORM writes the SQL for you.9. What is the best single reason to add
golang.org/x/sync/errgroup?Answer: Bounded concurrency with
SetLimitplus first-error cancellation, in a few linesIt turns a 25-line worker pool into about 8 lines and cancels the rest on the first error. It is one of the clearest cases in Go for taking a dependency.
10. How should you judge whether a package is safe to depend on?
Answer: Last commit, open issues, what
go mod graphpulls in, andgovulncheckStars measure attention at some point in the past. What matters is whether it is maintained now and how much it drags into your build.