Reputation: 105
I am getting a error when I am trying to run go build
, Error is something like this :
go: golang.org/x/[email protected] used for
two different module paths (github.com/golang/lint and golang.org/x/lint)
and my go.mod file is like
module gitlab.com/proj-ride/proj-src/services/event
go 1.14
require (
github.com/golang/protobuf v1.4.3
github.com/google/go-cmp v0.5.4 // indirect
golang.org/dl v0.0.0-20210220033039-562909534da3 // indirect
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5 // indirect
golang.org/x/tools v0.1.0 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/protobuf v1.25.0
)
replace github.com/golang/lint => golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5
EDIT
In case if I don't use `replace github.com/golang/lint`
my go.sum file contain it like this
github.com/golang/lint v0.0.0-20180702182130-06c8688daad7 h1:2hRPrmiwPrp3fQX967rNJIhQPtiGXdlQWAxKbKw3VHA=
github.com/golang/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E=
github.com/golang/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
how I can replace this with ?
golang.org/x/lint
as there are versions mentioned
Upvotes: 4
Views: 13166
Reputation: 1515
go mod tidy
might be useful to clear unwanted dependencies.
In this case, the message reports that one dependency is required by separate modules:
go: golang.org/x/[email protected] used for
two different module paths (github.com/golang/lint and golang.org/x/lint)
It is always better to upgrade to latest version as feasible. When using replace, the path remains as explained in the documentation.
Excluding the older dependency might work if compatibility is preserved by the latest dependency. Directive spells like: exclude github.com/golang/lint
Upvotes: 5