SoFunction
Updated on 2025-03-04

go mod tidy error:zip: not a valid zip file solution

Specific error:

User@3-WIN10BG0088 MINGW64 /d/Users/WorkSpace/Go/projects/gin-study
$ go get /gin-gonic/gin
go: downloading /gin-gonic/gin v1.9.1
go: /gin-gonic/gin: zip: not a valid zip file

User@3-WIN10BG0088 MINGW64 /d/Users/WorkSpace/Go/projects/gin-study
$ go env | grep PROXY
set GONOPROXY=
set GOPROXY=/goproxy/,direct

Solution:

Method 1: Execute go clean -modcache to clean the cache (invalid)

User@3-WIN10BG0088 MINGW64 /d/Users/WorkSpace/Go/projects/gin-study
$ go clean -modcache

User@3-WIN10BG0088 MINGW64 /d/Users/WorkSpace/Go/projects/gin-study
$ go mod tidy
go: finding module for package /gin-gonic/gin
go: downloading /gin-gonic/gin v1.9.1
go: /ice-fire-song/gin-study imports
        /gin-gonic/gin: zip: not a valid zip file

Method 2: Replace GOPROXY as Qiniu Cloud's * (valid)

User@3-WIN10BG0088 MINGW64 /d/Users/WorkSpace/Go/projects/gin-study
$ go env -w GOPROXY=",direct"

User@3-WIN10BG0088 MINGW64 /d/Users/WorkSpace/Go/projects/gin-study
$ go env|grep PROXY
set GONOPROXY=
set GOPROXY=,direct

User@3-WIN10BG0088 MINGW64 /d/Users/WorkSpace/Go/projects/gin-study
$ go mod tidy
go: finding module for package /gin-gonic/gin
go: downloading /gin-gonic/gin v1.9.1
go: found /gin-gonic/gin in /gin-gonic/gin v1.9.1
go: downloading /gin-contrib/sse v0.1.0
go: downloading /mattn/go-isatty v0.0.19
go: downloading /x/net v0.10.0
go: downloading /stretchr/testify v1.8.3
go: downloading /protobuf v1.30.0
go: downloading /go-playground/validator/v10 v10.14.0
go: downloading /pelletier/go-toml/v2 v2.0.8
go: downloading /ugorji/go/codec v1.2.11
go: downloading /yaml.v3 v3.0.1
go: downloading /bytedance/sonic v1.9.1
go: downloading /goccy/go-json v0.10.2
go: downloading /json-iterator/go v1.1.12
go: downloading /x/sys v0.8.0
go: downloading /davecgh/go-spew v1.1.1
go: downloading /pmezard/go-difflib v1.0.0
go: downloading /gabriel-vasile/mimetype v1.4.2
go: downloading /go-playground/universal-translator v0.18.1
go: downloading /leodido/go-urn v1.2.4
go: downloading /x/crypto v0.9.0
go: downloading /x/text v0.9.0
go: downloading /go-playground/locales v0.14.1
go: downloading /modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd
go: downloading /modern-go/reflect2 v1.0.2
go: downloading /chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311
go: downloading /x/arch v0.3.0
go: downloading /twitchyliquid64/golang-asm v0.15.1
go: downloading /klauspost/cpuid/v2 v2.2.4
go: downloading /go-playground/assert/v2 v2.2.0
go: downloading /google/go-cmp v0.5.5
go: downloading /check.v1 v0.0.0-20161208181325-20d25e280405
go: downloading /x/xerrors v0.0.0-20191204190536-9bdfabe68543

Summarize

This is the article about the solution to go mod tidy error: zip: not a valid zip file. For more related go mod tidy errors, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!