go: cmd/go: mod verify fails if directory entries are in zip file
What version of Go are you using (go version
)?
$ go version go version go1.18.3 linux/amd64
Does this issue reproduce with the latest release?
I think so
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env GO111MODULE="" GOARCH="amd64" GOBIN="" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPRIVATE="" GOPROXY="https://proxy.golang.org" GOROOT="/usr/lib/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64" GOVCS="" GOVERSION="go1.18.3" GCCGO="gccgo" GOAMD64="v1" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOWORK="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build456399546=/tmp/go-build -gno-record-gcc-switches"
What did you do?
go mod verify
fails immediately on freshly downloaded modules. This can be reproduced with a hermetic Docker setup:
Dockerfile:
FROM docker.io/library/golang:alpine as builder
WORKDIR /usr/src/app
COPY go.mod go.sum ./
RUN go mod download && go mod verify
COPY . .
RUN go build -v .
go.mod:
module example
go 1.18
require go.felesatra.moe/cloudflare v0.3.0
main.go:
package main
import (
"go.felesatra.moe/cloudflare"
)
func main() {
_ := cloudflare.Client{}
}
I suspect there’s something weird about the module zip files I build for go.felesatra.moe/cloudflare
, but I’m not sure where to start looking.
Also, it seems strange how go mod verify
could fail. If I understand correctly, it’s checking that the downloaded zip and the unpacked dir haven’t been modified, and given the above hermetic Docker reproduction I don’t see how that could be the case.
What did you expect to see?
No error
What did you see instead?
go mod verify
says the downloaded dir has been modified
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 16 (13 by maintainers)
@darkfeline, the zip format is documented in https://go.dev/ref/mod#zip-files, and is not the same as what is produced by
git archive
.That reference does currently state that “Empty directories (entries with paths ending with a slash) may be included in module zip files but are not extracted. The go command does not include empty directories in zip files it creates.” However, in light of the checksum mismatches caused by those entries, it seems clear to me that it needs to be revised.