go mod tidy报错:zip: not a valid zip file解决办法

 更新时间:2024年01月15日 08:37:13   作者:暗夜辰星  
这篇文章主要给大家介绍了关于go mod tidy报错:zip: not a valid zip file的解决办法,go mod是进行代码管理,这错误是因为本地分支和远程分支冲突,本文通过代码介绍的非常详细,需要的朋友可以参考下

具体报错:

User@3-WIN10BG0088 MINGW64 /d/Users/WorkSpace/Go/projects/gin-study
$ go get github.com/gin-gonic/gin
go: downloading github.com/gin-gonic/gin v1.9.1
go: github.com/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=https://mirrors.aliyun.com/goproxy/,direct

解决方式:

方式1:执行 go clean -modcache清理缓存(无效)

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 github.com/gin-gonic/gin
go: downloading github.com/gin-gonic/gin v1.9.1
go: github.com/ice-fire-song/gin-study imports
        github.com/gin-gonic/gin: zip: not a valid zip file

方式2:更换GOPROXY为七牛云的go代理(有效)

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

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

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

总结 

到此这篇关于go mod tidy报错:zip: not a valid zip file解决办法的文章就介绍到这了,更多相关go mod tidy报错内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

相关文章

  • 一文带你探索Go语言中crypto/md5标准库的强大功能

    一文带你探索Go语言中crypto/md5标准库的强大功能

    我们将从MD5算法的基础知识入手,逐步深入到如何在Go中有效使用crypto/md5标准库,包括基本的使用方法、实际应用案例分析,以及性能和安全性的考量,需要的可以参考下
    2024-02-02
  • win7下配置GO语言环境 + eclipse配置GO开发

    win7下配置GO语言环境 + eclipse配置GO开发

    这篇文章主要介绍了win7下配置GO语言环境 + eclipse配置GO开发,需要的朋友可以参考下
    2014-10-10
  • 通过示例深度理解Go channel range

    通过示例深度理解Go channel range

    这篇文章主要为大家介绍了Go channel range使用示例深度理解,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪
    2023-05-05
  • Golang使用channel实现数据汇总的方法详解

    Golang使用channel实现数据汇总的方法详解

    这篇文章主要为大家详细介绍了在并发编程中数据汇总的问题,并探讨了在并发环境下使用互斥锁和通道两种方式来保证数据安全性的方法,需要的可以参考一下
    2023-05-05
  • GoLang bytes.Buffer基础使用方法详解

    GoLang bytes.Buffer基础使用方法详解

    Go标准库中的bytes.Buffer(下文用Buffer表示)类似于一个FIFO的队列,它是一个流式字节缓冲区,我们可以持续向Buffer尾部写入数据,从Buffer头部读取数据。当Buffer内部空间不足以满足写入数据的大小时,会自动扩容
    2023-03-03
  • Makefile构建Golang项目示例详解

    Makefile构建Golang项目示例详解

    这篇文章主要为大家介绍了Makefile构建Golang项目的过程示例详解,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪
    2022-07-07
  • 执行go build报错go: go.mod file not found in current directory or any parent directory

    执行go build报错go: go.mod file not found in current dir

    本文主要为大家介绍了执行go build报错go: go.mod file not found in current directory or any parent directory解决分析,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪
    2023-06-06
  • 深入理解Golang之http server的实现

    深入理解Golang之http server的实现

    这篇文章主要介绍了深入理解Golang之http server的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2019-11-11
  • go语言基础语法示例

    go语言基础语法示例

    这篇文章主要介绍了go语言基础语法示例,介绍了go语言较为全面的基础知识,具有一定参考价值,需要的可以了解下。
    2017-11-11
  • Golang实现解析JSON的三种方法总结

    Golang实现解析JSON的三种方法总结

    这篇文章主要为大家详细介绍了Golang实现解析JSON的三种方法,文中的示例代码讲解详细,对我们学习了解JSON有一定帮助,需要的可以参考一下
    2022-09-09

最新评论