For this error:

      github.com/golang/lint@v0.0.0-20190409202823-959b441ac422: parsing 
go.mod: unexpected module path "golang.org/x/lint"

That is saying 'github.com/golang/lint' was loaded, but the 'go.mod' found 
at that location for that version had a different module name 
('golang.org/x/lint') declared in the go.mod there. The 'go' command does 
not allow that mismatch between how a module is referenced vs. how the 
module declares its identity in its go.mod.

You can probably make it work by adding a 'replace' statement for 
github.com/golang/lint using the version from just before the 'go.mod' was 
added there.

Here is an example.

First, verify we get a similar failure with 'go get -u' for this old 
version of zipkin-go:
    $ cd $(mktemp -d)
    $ git clone -b v0.1.5 --depth=1 https://github.com/openzipkin/zipkin-go 
.
    $ go get -u 
  
...which fails with the same error you reported:
      github.com/golang/lint@v0.0.0-20190409202823-959b441ac422: parsing 
go.mod: unexpected module path "golang.org/x/lint"

We can add a replace for the version of github.com/golang/lint from just 
before the 'go.mod' was added there. This will be a temporary measure that 
allows this upgrade to succeed, and then 'go mod tidy' will drop 
github.com/golang/lint from the module graph as no longer needed in this 
case.

   $ echo 'replace github.com/golang/lint => github.com/golang/lint 
5614ed5bae' >> go.mod
   $ go get -u
   $ go mod tidy
   $ go mod graph | grep github.com/golang/lint

...which now succeeds, and the grep finds nothing for the older github.com 
name.

There is a good chance that technique will work for you. There is a longer 
explanation of why that error occurs and why that technique usually works 
in this troubleshooting FAQ on the "Modules" wiki:

    
https://github.com/golang/go/wiki/Modules#how-can-i-resolve-parsing-gomod-unexpected-module-path-and-error-loading-module-requirements-errors-caused-by-a-mismatch-between-import-paths-vs-declared-module-identity

An alternative solution can be to try with the tip / master version of Go, 
which has better upgrade logic that can often sidestep this problem, and 
also often has a better error message for this situation:

   $ go get golang.org/dl/gotip && gotip download
   $ gotip get -u all
   $ gotip mod tidy

Hope that helps, but reply back to the list with more details if it does 
not.

Regards,
thepudds

On Monday, June 3, 2019 at 9:52:52 AM UTC-4, Joseph Lorenzini wrote:
>
> Hi all,
>
> I've been happily using go modules for several months. A couple days ago, 
> I decided to update my dependencies with go get -u. This failed with:
>
> go: github.com/golang/lint@v0.0.0-20190409202823-959b441ac422: parsing 
> go.mod: unexpected module path "golang.org/x/lint"
>
> Which led me to: https://github.com/golang/go/issues/30831
>
> So then I added a replace directive but that failed too because of 
> https://github.com/golang/go/issues/26904
>
> Which means as long as I depend on the golint package,  then go get -u 
> will not work. And then it occurred to me: how and why is this package 
> being pulled in? If i can remove my module's transitive dependency on 
> golint, then go get -u will start working. So I first ran go mod tidy. 
> Then I used go mod why however that was no help because whenever i executed 
> go mod why on the module, this is the output returned:
>
> (main module does not need module github.com/golang/lint)
>
> I also verified that github.com/golang/lint is not in my go.mod after 
> running go mod tidy. My understanding of tidy is that it pulls in direct 
> and transitive module dependencies ergo if go get -u is trying to upgrade 
> my deps according to go.mod, then it should be in my go.mod. So I am 
> stumped why go get -u is trying to upgrade golint, when according to go mod 
> tidy, my go.mod file, and go mod why, I don't have a dependency on it.
>
> Any advice would be appreciated.
>
> Thanks,
> Joe
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/3dc32542-d423-4920-a6ff-d4171b4667ad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to