You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用gqlgen生成GraphQL schema时出现missing go.sum entry错误求助

解决gqlgen生成Schema时的missing go.sum entry错误

问题重现

执行gqlgen生成命令:

go run github.com/99designs/gqlgen generate

出现以下错误:

..\..\..\..\..\go\pkg\mod\github.com\99designs\gqlgen@v0.17.33\main.go:20:2: missing go.sum entry for module providing package github.com/urfave/cli/v2 (imported by github.com/99designs/gqlgen); to add:        
go get github.com/99designs/gqlgen@v0.17.33
..\..\..\..\..\go\pkg\mod\github.com\99designs\gqlgen@v0.17.33\codegen\field.go:16:2: missing go.sum entry for module providing package golang.org/x/text/cases (imported by github.com/99designs/gqlgen/codegen); to add:
go get github.com/99designs/gqlgen/codegen@v0.17.33
..\..\..\..\..\go\pkg\mod\github.com\99designs\gqlgen@v0.17.33\codegen\field.go:17:2: missing go.sum entry for module providing package golang.org/x/text/language (imported by github.com/99designs/gqlgen/codegen); to add:
go get github.com/99designs/gqlgen/codegen@v0.17.33
..\..\..\..\..\go\pkg\mod\github.com\99designs\gqlgen@v0.17.33\internal\imports\prune.go:15:2: missing go.sum entry for module providing package golang.org/x/tools/go/ast/astutil (imported by github.com/99designs/gqlgen/internal/imports); to add:
go get github.com/99designs/gqlgen/internal/imports@v0.17.33
..\..\..\..\..\go\pkg\mod\github.com\99designs\gqlgen@v0.17.33\internal\code\packages.go:14:2: missing go.sum entry for module providing package golang.org/x/tools/go/packages (imported by github.com/99designs/gqlgen/codegen/config); to add:
go get github.com/99designs/gqlgen/codegen/config@v0.17.33
..\..\..\..\..\go\pkg\mod\github.com\99designs\gqlgen@v0.17.33\internal\imports\prune.go:16:2: missing go.sum entry for module providing package golang.org/x/tools/imports (imported by github.com/99designs/gqlgen/internal/imports); to add:
go get github.com/99designs/gqlgen/internal/imports@v0.17.33

原因分析

这类错误是因为go.sum文件缺少gqlgen及其子模块依赖的校验条目,Go模块需要这些条目验证依赖包的完整性和一致性,避免依赖被篡改。

解决步骤

  1. 安装指定版本的gqlgen,补全主模块的sum条目:
go get github.com/99designs/gqlgen@v0.17.33
  1. 自动整理所有依赖,补全缺失的sum条目并清理无用依赖:
go mod tidy
  1. 重新执行gqlgen生成命令:
go run github.com/99designs/gqlgen generate

内容的提问来源于stack exchange,提问作者judith herlambang

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.18 14:43:03