【FIX】go运行报错“missing go.sum entry for module providing package”解决方案

🔧 ​核心解决方案

  1. **运行 go mod tidy**​

    作用​:自动同步 go.modgo.sum文件,添加缺失依赖并移除无用条目。

    go mod tidy
    

    适用场景​:90% 的校验和缺失问题可通过此命令解决。

    注意​:若项目含私有仓库,需提前配置 GOPRIVATE环境变量。

  2. 清理模块缓存后重建

    步骤​:

    go clean -modcache   # 清除本地模块缓存
    go mod tidy          # 重新下载依赖并生成校验和
    

    适用场景​:缓存损坏或依赖版本冲突时(如依赖被意外修改)。

    影响​:首次重建可能耗时较长(需重新下载所有依赖)。

  3. 手动添加缺失依赖

    步骤​:

    go get github.com/gin-contrib/sse@latest  # 下载最新版本
    go mod tidy                                 # 更新校验
Build Error: go build -o e:\易通\后端\aijiafu\__debug_bin3519557559.exe -gcflags all=-N -l . session\rdb\conn.go:7:2: missing go.sum entry for module providing package github.com/redis/go-redis/v9 (imported by git.kaifakuai.com/docker/aijiafu/session/rdb); to add: go get git.kaifakuai.com/docker/aijiafu/session/rdb store\contract.go:6:2: missing go.sum entry for module providing package github.com/sirupsen/logrus (imported by git.kaifakuai.com/docker/aijiafu/api/device); to add: go get git.kaifakuai.com/docker/aijiafu/api/device store\store.go:7:2: missing go.sum entry for module providing package gorm.io/driver/postgres (imported by git.kaifakuai.com/docker/aijiafu/store); to add: go get git.kaifakuai.com/docker/aijiafu/store store\device_realtime.go:6:2: missing go.sum entry for module providing package gorm.io/gorm (imported by git.kaifakuai.com/docker/aijiafu/api/device); to add: go get git.kaifakuai.com/docker/aijiafu/api/device store\store.go:9:2: missing go.sum entry for module providing package gorm.io/gorm/logger (imported by git.kaifakuai.com/docker/aijiafu/store); to add: go get git.kaifakuai.com/docker/aijiafu/store store\store.go:10:2: missing go.sum entry for module providing package gorm.io/gorm/schema (imported by git.kaifakuai.com/docker/aijiafu/store); to add: go get git.kaifakuai.com/docker/aijiafu/store base\auth.go:8:2: missing go.sum entry for module providing package github.com/gin-gonic/gin (imported by git.kaifakuai.com/docker/aijiafu/api/device); to add: go get git.kaifakuai.com/docker/aijiafu/api/device base\jwt.go:12:2: missing go.sum entry for module providing package github.com/golang-jwt/jwt (imported by git.kaifakuai.com/docker/aijiafu/base); to add: go get git.kaifakuai.com/docker/aijiafu/base api\device\mqtt.go:9:2: missing go.sum entry for module providing package github.com/eclipse/paho.mqtt.golang (imported by git.kaifakuai.com/docker/aijiafu/api/device); to add: go get git.kaifakuai.com/docker/aijiafu/api/device api\device\info.go:16:2: missing go.sum entry for module providing package github.com/jackc/pgx/v5/pgconn (imported by git.kaifakuai.com/docker/aijiafu/api/device); to add: go get git.kaifakuai.com/docker/aijiafu/api/device session\mqttec\conn.go:8:2: missing go.sum entry for module providing package github.com/google/uuid (imported by git.kaifakuai.com/docker/aijiafu/session/mqttec); to add: go get git.kaifakuai.com/docker/aijiafu/session/mqttec (exit status 1)
最新发布
06-20
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值