Format:Go module zip
| Magic | PK\x03\x04 (ZIP) |
|---|---|
| Extensions | .zip (proxy URL .../@v/<version>.zip) |
| On this wiki | Facts · Code · Notes · Topics |
The module zip served by Go module proxies: a ZIP whose every file path starts with module@version/, containing the module's source (no vendor directories or nested modules, no symlinks); integrity is the h1: dirhash recorded in go.sum, SHA-256 over per-file hashes, independent of zip encoding.
A Go module version is distributed as a ZIP created by golang.org/x/mod/zip (zip.go, BSD-3-Clause). Rules given in the package documentation:
- Every file path begins with
<module path>@<version>/; the version must be canonical and the module path must carry a consistent major-version suffix. - No two file paths may be equal under Unicode case folding.
- A
go.modmay appear only in the top-level directory and must be lower-case;go.modfiles elsewhere are not allowed (nested modules are left out when creating the zip). - At most 500 MiB for the zip and for the total uncompressed size (
MaxZipFile);go.modandLICENSEat the root at most 16 MiB each. - Each file's uncompressed size must match its declared 64-bit size. Empty directories are ignored; permissions and timestamps are ignored; symbolic links and irregular files are not allowed.
- Creation skips vendored packages and vendor directories (files under
vendor/; since Go 1.24 in go.modvendor/modules.txtis dropped as well, with the older behavior kept for older language versions).
The go.sum hash
golang.org/x/mod/sumdb/dirhash Hash1 produces h1: followed by base64 of the SHA-256 of a text summary with one line per file sorted by name: the lowercase hex SHA-256 of the content, two spaces, the file name (including the module@version/ prefix), newline, as if by sha256sum $(find . -type f | sort) | sha256sum. HashZip hashes only file names and contents, so compression method, timestamps and zip metadata do not matter: two byte-different zips can have the same h1 hash. go.sum lines have the form module version h1:... for the zip and module version/go.mod h1:... for the go.mod file alone (Unverified: the /go.mod line form is from general knowledge, it is not in the files read).
Where code runs
Go has no install-time scripts: go mod download and go build only fetch and compile. Code runs when you build or run a program that imports the package; go generate and cgo are separate steps the consumer invokes (Unverified: this statement is general knowledge, not read from the toolchain source).
Code & repositories
- https://github.com/golang/mod @
b5136e5ba156da612a1efc6e49b55988a134a5e0· license: BSD-3-Clause (declared by the contributor for the files used; GitHub reports BSD-3-Clause (read from LICENSE; GitHub's API was busy) for the repository)
golang.org/x/mod: zip/zip.go (module zip rules) and sumdb/dirhash (h1 hash).
Tested on: source read, not run · checked 2026-10-19
See also
Technique:Install-time code execution in package archives, Library:Go runtime for the build-info a Go binary stores about the modules it was built from.