Skip to content
This repository has been archived by the owner on May 9, 2021. It is now read-only.

parsing go.mod: unexpected module path "golang.org/x/lint" #446

Closed
psampaz opened this issue Apr 2, 2019 · 12 comments
Closed

parsing go.mod: unexpected module path "golang.org/x/lint" #446

psampaz opened this issue Apr 2, 2019 · 12 comments

Comments

@psampaz
Copy link

psampaz commented Apr 2, 2019

When i run

go get -u 

I get the following error:

go: github.com/golang/[email protected]: parsing go.mod: unexpected module path "golang.org/x/lint"

My go.mod file is the following:

module mymodule

go 1.12

require (
	github.com/aws/aws-sdk-go v1.18.5
	github.com/cespare/xxhash v1.1.0 // indirect
	github.com/coocood/freecache v1.1.0
	github.com/gemnasium/logrus-graylog-hook/v3 v3.0.2
	github.com/kr/pretty v0.1.0 // indirect
	github.com/pkg/errors v0.8.1
	github.com/sirupsen/logrus v1.4.0
	github.com/spf13/viper v1.3.2
	github.com/streadway/amqp v0.0.0-20190312223743-14f78b41ce6d
	github.com/uber-go/atomic v1.3.2 // indirect
	go.etcd.io/bbolt v1.3.2
	go.uber.org/atomic v1.3.2 // indirect
	go.uber.org/ratelimit v0.0.0-20180316092928-c15da0234277
	golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a
	golang.org/x/net v0.0.0-20190318221613-d196dffd7c2b
	golang.org/x/oauth2 v0.0.0-20190319182350-c85d3e98c914
	golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6
	google.golang.org/api v0.2.0
)

My Go version is:

go version go1.12.1 linux/amd64

the output of go get -u is the following

go: finding github.com/alecthomas/template latest
go: finding github.com/mwitkow/go-conntrack latest
go: finding golang.org/x/net latest
go: finding gopkg.in/check.v1 latest
go: finding golang.org/x/crypto latest
go: finding github.com/prometheus/client_model latest
go: finding golang.org/x/exp latest
go: finding golang.org/x/sync latest
go: finding github.com/armon/consul-api latest
go: finding go.uber.org/ratelimit latest
go: finding google.golang.org/genproto latest
go: finding golang.org/x/oauth2 latest
go: finding github.com/kr/logfmt latest
go: finding golang.org/x/tools latest
go: finding github.com/beorn7/perks latest
go: finding github.com/BurntSushi/xgb latest
go: finding github.com/prometheus/procfs latest
go: finding golang.org/x/image latest
go: finding golang.org/x/sys latest
go: finding github.com/streadway/amqp latest
go: finding golang.org/x/lint latest
go: finding github.com/jmespath/go-jmespath latest
go: finding honnef.co/go/tools latest
go: finding github.com/ugorji/go/codec latest
go: finding golang.org/x/time latest
go: finding github.com/alecthomas/units latest
go: finding golang.org/x/build latest
go: finding github.com/jellevandenhooff/dkim latest
go: finding github.com/eapache/go-xerial-snappy latest
go: finding github.com/flynn/go-shlex latest
go: finding github.com/jstemmer/go-junit-report latest
go: finding github.com/anmitsu/go-shlex latest
go: finding github.com/bradfitz/go-smtpd latest
go: finding github.com/google/pprof latest
go: finding gopkg.in/tomb.v1 latest
go: finding github.com/golang/glog latest
go: finding github.com/rcrowley/go-metrics latest
go: finding github.com/tarm/serial latest
go: finding github.com/golang/lint latest
go: finding github.com/gregjones/httpcache latest
go: finding golang.org/x/mobile latest
go: github.com/golang/[email protected]: parsing go.mod: unexpected module path "golang.org/x/lint"
go: finding grpc.go4.org latest
go: finding github.com/coreos/go-systemd latest
go: finding go4.org latest
go get: error loading module requirements
@frieser
Copy link

frieser commented Apr 3, 2019

Same error

@alexandrevilain
Copy link

Same error too!

go version go1.12 linux/amd64

@grempe
Copy link

grempe commented Apr 3, 2019

I am also seeing this issue when using go get -u for the dependency I'm trying to update. If I remove the -u it works. Perhaps this issue has come alive again since re-adding the go.mod file?

#436

...
get "go4.org": found meta tag get.metaImport{Prefix:"go4.org", VCS:"git", RepoRoot:"https://github.com/go4org/go4"} at https://go4.org?go-get=1
go: finding github.com/golang/lint latest
go: github.com/golang/[email protected]: parsing go.mod: unexpected module path "golang.org/x/lint"
go: finding go4.org latest
go get: error loading module requirements

@psampaz
Copy link
Author

psampaz commented Apr 6, 2019

related issue on main Go repo golang/go#30831

@matthijskooijman
Copy link

Also see golang/go#30833 and #436

@matthijskooijman
Copy link

The problem is that some package in your dependency graph is still referencing github.com/golang/lint, rather than golang.org/x/lint. Due to golang/go#30833 this problem surfaces even when an older version of a module has the incorrect reference. That is, even if the package directly depending lint is fixed, as long as some other package depends on an older version of that directly depending package, this problem will still trigger. To fix this, you will have to make sure that all incorrect references are gone from your module graph (which likely requires updating one or more modules on the dependency path from your project to lint and them manually upgrading the first modules on that path).

See sourcegraph/go-diff#34 for some discussion of essentially the same issue in go-diff, along with some suggestions to use gotip for a more useful error message.

As a workaround, I think you can use a replace directive to point to the right repo:

go mod edit -replace github.com/golang/lint=golang.org/x/lint@latest

Note that this adds a line to go.mod, but the latest here is replaced by an actual version number when the go.mod is rewritten (so you might need to update that later).

This bug is indeed triggered by re-adding the go.mod file, since that causes a problem when the import path inside the go.mod file does not match the import path used in the depending module.

@matthijskooijman
Copy link

@psampaz, I just tested with your go.mod file and can reproduce your problem. Using gotip, I get:

$ gotip get -u -m
[ snip output]
go get: [email protected] ->
        google.golang.org/[email protected] ->
        google.golang.org/[email protected] ->
        github.com/golang/[email protected] ->
        github.com/golang/[email protected]: parsing go.mod: unexpected module path "golang.org/x/lint"

This shows the path of modules that pull in the faulty lint. I know that grpc has a fixed version, I can see that https://github.com/google/go-genproto/blob/master/go.mod has a fixed version, so that leaves only opencensus. I couldn't find any sources, but I just tried upgrading it manually, which seems to work. That is, running go get -u -m go.opencensus.io followed by go get -u -m completes successfully. Note that the -m is optional, AFAIU it just prevents actually installing stuff into your $GOPATH (for non-module-enabled code to use) and only updates it in your go.mod and downloads it for module-enable code to use.

matthijskooijman added a commit to 3devo/DvConnector that referenced this issue Apr 16, 2019
This updates all (indirect) dependencies to their latest versions. There
is a problem in go (hopefully will be fixed in 1.13).  This problem
causes problems when modules are renamed or moved and manifested with
the go-diff and lint packages.

The problem has been worked around in various packages, but this
requires manually updating some packages before doing a full update.
This commit was generated using:

  go get -u -m github.com/gobuffalo/buffalo-plugins
  go get -u -m
  go mod tidy

See also:
 - golang/go#30831
 - sourcegraph/go-diff#34
 - golang/lint#446
@psampaz
Copy link
Author

psampaz commented Apr 16, 2019

thank you @matthijskooijman for your explanatory comments. They were really helpful.

I hope this gets fixed properly on the next version of Go.

@matthijskooijman
Copy link

matthijskooijman commented Apr 24, 2019

For anyone looking to solve this problem, @jadekler has written (somewhat extensively) about this issue and how to fix it at https://github.com/golang/go/wiki/Resolving-Problems-From-Modified-Module-Path.

@rdhariwal
Copy link

For anyone looking to solve this problem, @jadekler has written (somewhat extensively) about this issue and how to fix it at https://golang/go/wiki/Resolving-Problems-From-Modified-Module-Path.

https://golang/go/wiki/Resolving-Problems-From-Modified-Module-Path
@matthijskooijman link is broken for me

@matthijskooijman
Copy link

W00ps, fixed the link. Copied it from a place where github had hidden the github.com part :-)

@mvdan
Copy link
Member

mvdan commented May 8, 2021

Thank you for submitting this issue! As per golang/go#38968, we are freezing and deprecating golint. There's no drop-in replacement to golint per se, but you should find that Staticcheck works well in encouraging good Go code, much like golint did in the past, since it also includes style checks. There's always gofmt and go vet too, of course.

If you would like to contribute further, I'd encourage you to engage Staticcheck's issue tracker or look at vet's open issues, as they are both actively maintained. If you have an idea that doesn't fit into either of those tools, you could look at other Go linters, or write your own - these days it's fairly straightforward with go/analysis.

To help avoid confusion, I'm closing all issues before we freeze the repository. If you have any feedback, you can leave a comment on the proposal thread where it was decided to deprecate golint - though note that the proposal has been accepted for nearly a year. Thanks!

@mvdan mvdan closed this as completed May 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants