Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Module declared as X but was required as Y

I'm trying to use grafana/grafana/pkg/tsdb package in my module. I don't think this problem is specific to grafana but here it goes:

$ go get -u github.com/grafana/grafana/pkg/tsdb
go: finding github.com/inconshreveable/log15 latest
go: finding github.com/go-macaron/session latest
go: finding golang.org/x/oauth2 latest
go: finding github.com/teris-io/shortid latest
go: github.com/grafana/grafana/pkg/tsdb imports
        github.com/go-xorm/core: github.com/go-xorm/[email protected]: parsing go.mod:
        module declares its path as: xorm.io/core
                but was required as: github.com/go-xorm/core

It says that the package tsdb is importing xorm as github.com/go-xorm/core, but the module declares itself as xorm.io/core.

Looking at Grafana's go.mod file, it's using github.com/go-xorm/core and going to github.com/go-xorm/core, it says the project is now archived... and it's go.mod file indeed declared itself as xorm.io/core...

and suggestions on how I can resolve this issue?

like image 513
kjq07bd Avatar asked Feb 21 '20 15:02

kjq07bd


People also ask

What is GO111MODULE?

GO111MODULE is an environment variable that can be set when using go for changing how Go imports packages. One of the first pain-points is that depending on the Go version, its semantics change.

How does go mod work?

Go modules commonly consist of one project or library and contain a collection of Go packages that are then released together. Go modules solve many problems with GOPATH , the original system, by allowing users to put their project code in their chosen directory and specify versions of dependencies for each module.


1 Answers

edit: I also had luck just using a slightly older version:

go get github.com/grafana/grafana/pkg/[email protected]

I tried a replace, which can work sometimes:

module foo

replace github.com/go-xorm/core => xorm.io/core v0.6.2

go 1.13

require (
...

but I get a type error.

Luckily it looks like there is a PR out to fix this issue: https://github.com/grafana/grafana/pull/22376

like image 90
maxm Avatar answered Sep 21 '22 19:09

maxm