缺少模块的 go.sum 条目,提供 package < package_name >

使用水牛框架, 通过 buffalo new <project_name>引导后

我正在尝试运行 buffalo dev 期待看到:

在3000端口上运行的项目

但是我却收到了这些错误消息

actions/app.go:4:2: missing go.sum entry for module providing package github.com/gobuffalo/buffalo (imported by sc_api/actions); to add:go get sc_api/actions


actions/app.go:13:2: missing go.sum entry for module providing package github.com/gobuffalo/mw-csrf (imported by sc_api/actions); to add: go get sc_api/actions

actions/app.go是由 Buffalo 生成的,但是如果您想知道错误是否与这个文件中的 import 语句相匹配的话。

// app.go
package actions


import (
"github.com/gobuffalo/buffalo"  // 1rst line
"github.com/gobuffalo/envy"
forcessl "github.com/gobuffalo/mw-forcessl"
paramlogger "github.com/gobuffalo/mw-paramlogger"
"github.com/unrolled/secure"


"sc_api/models"


"github.com/gobuffalo/buffalo-pop/v2/pop/popmw"
csrf "github.com/gobuffalo/mw-csrf"  // 2nd line
i18n "github.com/gobuffalo/mw-i18n"
"github.com/gobuffalo/packr/v2"
)

这是什么意思? 我该怎么补救?

79818 次浏览

It seems the issue has nothing to do with Buffalo and more with my lack of understanding of Go in general.

running go mod tidy solved the issue

This command goes through the go.mod file to resolve dependencies:

  • delete the packages that are not needed
  • download those needed
  • update the go.sum

I am still unsure which of those actions did the trick... but the project runs now.

ps: I'll let the in-depth explanation/correction to the Go wizard out here.

i got the same issue when building a docker image. i tried go mod tidy and also go get -t . as suggested here https://github.com/golang/go/issues/44129. both didnt worked for me though but updating my docker builder to version 1.18 worked.