Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

missing go.sum entry for module providing package <package_name>

Using the buffalo framework, after bootstraping it via buffalo new <project_name>

I am trying to run buffalo dev Expecting to see:

project running on port 3000

But I am getting those error messages instead

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 has been generated by buffalo, but in case you are wondering the error does match the import statement in this file.

// 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"
)

What does it mean ? How do I fix it ?

like image 990
Paulo Avatar asked Apr 21 '21 21:04

Paulo


People also ask

How do you update a go module?

You can upgrade or downgrade a dependency module by using Go tools to discover available versions, then add a different version as a dependency. To discover new versions use the go list command as described in Discovering available updates.

What does go mod tidy do?

go mod tidy ensures that the go. mod file matches the source code in the module. It adds any missing module requirements necessary to build the current module's packages and dependencies, if there are some not used dependencies go mod tidy will remove those from go.

How do I get go dependencies?

To install dependencies, use the go get command, which will also update the go. mod file automatically. Since the package is not currently used anywhere in the project, it's marked as indirect. This comment may also appear on an indirect dependency package; that is, a dependency of another dependency.


2 Answers

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.

like image 74
Paulo Avatar answered Oct 20 '22 01:10

Paulo


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.

like image 6
Stanley Coffey Avatar answered Oct 20 '22 03:10

Stanley Coffey