go build遇见“module *** found, but does not contain package ***”

在实际项目中编译版本时遇见以下问题:

common/middleware/sentinel.go:4:2: module github.com/alibaba/sentinel-golang@latest found (v1.0.2), but does not contain package github.com/alibaba/sentinel-golang/adapter/gin

解决方案:

  1. 首先进入github.com/alibaba/sentinel-golang
  2. 切换tag,查看最新的包含package github.com/alibaba/sentinel-golang/adapter/gin的版本
  3. 适用如下命令:
go mod edit -replace github.com/alibaba/sentinel-golang=github.com/alibaba/[email protected]
  1. 再继续go build即可
[root@VM-0-17-centos go-admin]# go build
go: downloading github.com/alibaba/sentinel-golang v0.6.2

你可能感兴趣的:(GO)