Golang version upgrade : Vendored module should be required explicitly in go.mod

1.6k Views Asked by At

I'm a beginnner to Golang and I have a Golang app running on v1.14. I upgraded the version of the app to 1.17 by doing the following

go mod edit -go=1.17

Upon doing this, and running go buildI see an error prompt which says:

go: vendored module gopkg.in/[email protected] should be required explicitly in go.mod
go: vendored module gopkg.in/[email protected] should be required explicitly in go.mod
go: vendored module gopkg.in/[email protected] should be required explicitly in go.mod

So I noticed these modules present in vendor/ directory and I have these dependencies in vendor/modules.txt as follows:

gopkg.in/ini.v1
gopkg.in/yaml.v2
gopkg.in/yaml.v3

I tried adding these dependencies in go.mod's require section as follows

module code/workers

go 1.17

require (
    ......
    gopkg.in/ini.v1 v1.62.0
)

Now when I run "go build", I get an inconsistent vendoring error

go: inconsistent vendoring in .../workers:
        gopkg.in/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt

Am I handling this in the right way?

0

There are 0 best solutions below