问题现象

在开发机上升级到了最新 golang 1.16.3 版本,在为一个基于 golang 1.13 的历史项目添加 excel 依赖包后

  1. go get github.com/360EntSecGroup-Skylar/excelize/v2

编译报错:

  1. go build ../../../golang/pkg/mod/golang.org/x/crypto@v0.0.0-20201012173705-84dcc777aaee/blake2b/blake2bAVX2_amd64.go:9:8: missing go.sum entry for module providing package golang.org/x/sys/cpu (imported by golang.org/x/crypto/blake2b); to add: go get golang.org/x/crypto/blake2b@v0.0.0-20201012173705-84dcc777aaee ../../../golang/pkg/mod/github.com/mattn/go-isatty@v0.0.8/isatty_tcgets.go:7:8: missing go.sum entry for module providing package golang.org/x/sys/unix (imported by github.com/mattn/go-isatty); to add: go get github.com/mattn/go-isatty@v0.0.8

主要错误就是这个

  1. missing go.sum entry for module providing package xxx

golang 版本

  1. go version
  1. go version go1.16.5 windows/amd64

解决方法

  1. go mod tidy

image.png
再次编译,就可以了。

go mod tidy 的作用

go mod tidy removes unused dependencies.
即,移除未使用的依赖。

参考

https://github.com/golang/go/issues/44129

原文链接

https://www.sunzhongwei.com/golang-1163-upgrade-compile-error-missing-sum-entry-for-module-providing-package