Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

go module @latest found but does not contain package

Tags:

module

go

I'm trying to make use of go module for the first time. What exactly the following error message is telling me?

module github.com/mkideal/cli@latest found (v0.2.2), but does not contain package github.com/mkideal/cli
module github.com/mkideal/cli@latest found (v0.2.2), but does not contain package github.com/mkideal/cli/ext

It happens during go build, whereas go get is just fine:

$ go get -v github.com/mkideal/cli
go: github.com/mkideal/cli upgrade => v0.2.2

but not go get -v ./..., which gave me the same error as above. My proxy setting looks OK:

$ go env | grep GOPROXY
GOPROXY="https://proxy.golang.org,direct"

Is it a problem of the go module/package I'm trying to use, or my own code's problem? -- I took a look at https://github.com/mkideal/cli/blob/master/go.mod and it seems fine to me.

See the following update for details.

How can I overcome the situation? (I'm getting the same error message for my own repo as well)

UPDATE:

Here is the full log how I'm getting the above error:

  • prepare /tmp/015-file from https://github.com/mkideal/cli/blob/master/_examples/015-file
  • do go mod init
  • then go build

Now the details:

$ cd /tmp/015-file

$ GO111MODULE=on

$ go mod init github.com/mkideal/cli/015-file
go: creating new go.mod: module github.com/mkideal/cli/015-file

$ cat go.mod 
module github.com/mkideal/cli/015-file

go 1.14

$ go build
go: finding module for package github.com/mkideal/cli
go: finding module for package github.com/mkideal/cli/ext
main.go:6:2: module github.com/mkideal/cli@latest found (v0.2.2), but does not contain package github.com/mkideal/cli
main.go:7:2: module github.com/mkideal/cli@latest found (v0.2.2), but does not contain package github.com/mkideal/cli/ext

$ go get -v github.com/mkideal/cli
go: github.com/mkideal/cli upgrade => v0.2.2

$ go get -v ./...
go: finding module for package github.com/mkideal/cli
go: finding module for package github.com/mkideal/cli/ext
go: finding module for package github.com/mkideal/cli
go: finding module for package github.com/mkideal/cli/ext
main.go:6:2: module github.com/mkideal/cli@latest found (v0.2.2), but does not contain package github.com/mkideal/cli
main.go:7:2: module github.com/mkideal/cli@latest found (v0.2.2), but does not contain package github.com/mkideal/cli/ext

$ go version
go version go1.14.1 linux/amd64


like image 789
xpt Avatar asked Jul 19 '20 00:07

xpt


4 Answers

Try clearing cache: go clean -modcache

For more info on how this command works, use go help clean

like image 148
Font Ding Avatar answered Oct 11 '22 04:10

Font Ding


  • Update to go version go1.14.3 linux/amd64
  • Clear go module cache

don't know which one solved the problem (or both), now AOK.

like image 32
xpt Avatar answered Oct 11 '22 04:10

xpt


In my case cleaning cache didn't help.
Running go install in a project root printed no Go files in ... and that was the root cause, in the same time running go install gitlab.com/.... printed info about a missing package.

What had to be done was creating a go file in a project root directory with main function.

like image 3
kabot Avatar answered Oct 11 '22 03:10

kabot


I had the same error, but in my case I was attempting to import a module that made available only resource files, and no go pkgs. Adding an empty go file in the module with a package declaration solved it.

like image 1
Shanjeef Avatar answered Oct 11 '22 03:10

Shanjeef