liveBook · Manning

Go.sum

As explained in Go in Action, Second Edition

go.sum is a Go module file containing cryptographic checksums for downloaded module dependencies.

A dependency version alone does not record the exact code downloaded for a build. Go pairs go.mod, which records module requirements, with go.sum, which stores cryptographic checksums for downloaded dependencies. Together they support auditable, reproducible builds. section 1.6 section 11.1

github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=

The two entries for github.com/gorilla/mux v1.8.0 record separate h1: checksums for the module source and its go.mod file. section 11.1

Use go get to add a dependency at the latest or a specified version, or add an import and run go mod tidy. Go maintains go.sum alongside go.mod. If a published dependency changes, its checksum no longer matches the recorded value, helping detect tampering. section 11.1

How Go in Action, Second Edition covers it

How deep it goes
Explains the two typical checksum entries and their tamper-detection role, without detailing the checksum algorithm.
Examples
Shows source-code and go.mod checksum entries for github.com/gorilla/mux v1.8.0.
What it assumes
Introduces module setup with go mod init before explaining dependency files and checksums.
What you can do after
Operate/configure it using go get or go mod tidy, and distinguish the two checksum entries for a dependency.
How it connects
Connects go.sum to go.mod, Go modules, dependency versioning, and reproducible builds.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Go in Action, Second Edition. The section links point to the parts of the book it draws on.